slack-ruby-block-kit 0.19.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 122d7e0273762e60628682a4874b0c5c148312b3cc62e9659c0c42dff2f200d6
4
- data.tar.gz: c5d1685745d2bf0bc12813e96ecd14c87a1a21fad9d81c27a29dac243891b1a9
3
+ metadata.gz: 5468729c5b17bca80befff3cb61182d2bb28cc5e72b04fe3f4712c7af9b9c201
4
+ data.tar.gz: 5dfe1013be40d5a50ca3d29c613da3452442e837df421d3716638e8b17de93e1
5
5
  SHA512:
6
- metadata.gz: 6e9df8d14a98baff1b3783c159527277d9e25d61f8fd68ff113d2449ad447611f80d1b023950733c1d159345d3359f6fe08c6bd70254b085ffbfa77613abd97b
7
- data.tar.gz: 3cd7a5724578d354345bfbe11014c37f8ce4d2515c59bfe2cfdd139aaee4fa8bd71418811abe59500c0bac3950d14bf91891053c247144df0d76b9f70142f165
6
+ metadata.gz: e33f622b3a8b6fcb925ace62fec77046c6ba461237bd17870233727630274ddd7c79e8a0e0d7341888866795d6382bdd014f5b3ae3cede0910304ae6d01e9c84
7
+ data.tar.gz: 49a1e0364f053e1d0c81830044be1bf93496276ea9d91cf9e35c42bcd601577b0442cfb1ee0d3f9a52e5e57a7ecece72a9363c28f9b9415861f210c217a8ce85
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '2.6', '2.7', '3.0' ]
19
+ ruby: [ '2.6', '2.7', '3.0', '3.1' ]
20
20
  experimental: [ false ]
21
21
  name: Ruby ${{ matrix.ruby }}
22
22
  steps:
data/.gitignore CHANGED
@@ -8,6 +8,7 @@
8
8
  /spec/reports/
9
9
  /spec/examples.txt
10
10
  /tmp/
11
+ .idea
11
12
 
12
13
  # rspec failure tracking
13
14
  .rspec_status
data/CHANGELOG.md CHANGED
@@ -25,6 +25,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
25
25
  ### Security
26
26
  - N/A
27
27
 
28
+ ## [0.21.0] - 2023-02-19
29
+
30
+ ### Added
31
+ - `Slack::BlockKit::Element::UrlTextInput` (#164 by @dimerman)
32
+ - `Slack::BlockKit::Element::EmailTextInput` (#166 by @CGA1123)
33
+ - `Slack::BlockKit::Element::Datetimepicker` (#167 by @CGA1123)
34
+
35
+ ## [0.20.0] - 2022-09-25
36
+
37
+ ### Added
38
+ - Added `focus_on_load` parameter to following elements (#153 by @aka-nez):
39
+ - `Slack::BlockKit::Element::ChannelsSelect`
40
+ - `Slack::BlockKit::Element::Checkboxes`
41
+ - `Slack::BlockKit::Element::ConversationsSelect`
42
+ - `Slack::BlockKit::Element::Datepicker`
43
+ - `Slack::BlockKit::Element::ExternalSelect`
44
+ - `Slack::BlockKit::Element::MultiChannelsSelect`
45
+ - `Slack::BlockKit::Element::MultiConversationsSelect`
46
+ - `Slack::BlockKit::Element::MultiExternalSelect`
47
+ - `Slack::BlockKit::Element::MultiStaticSelect`
48
+ - `Slack::BlockKit::Element::MultiUsersSelect`
49
+ - `Slack::BlockKit::Element::PlainTextInput`
50
+ - `Slack::BlockKit::Element::RadioButtons`
51
+ - `Slack::BlockKit::Element::StaticSelect`
52
+ - `Slack::BlockKit::Element::Timepicker`
53
+ - `Slack::BlockKit::Element::UsersSelect`
54
+
28
55
  ## [0.19.0] - 2022-09-05
29
56
 
30
57
  ### Added
@@ -135,7 +162,9 @@ This release contains a breaking change on the `Layout::Actions` interface.
135
162
  - Fixed initial options in multi select blocks (#46 by @caalberts)
136
163
 
137
164
 
138
- [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.19.0...HEAD
165
+ [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.21.0...HEAD
166
+ [0.21.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.20.0...v0.21.0
167
+ [0.20.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.19.0...v0.20.0
139
168
  [0.19.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.18.0...v0.19.0
140
169
  [0.18.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.17.0...v0.18.0
141
170
  [0.17.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.16.0...v0.17.0
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gem 'faraday', '~> 1'
9
9
  gem 'pry', '~> 0.14'
10
10
  gem 'rake', '~> 13'
11
11
  gem 'rspec', '~> 3'
12
- gem 'rspec_junit_formatter', '~> 0.5'
12
+ gem 'rspec_junit_formatter', '~> 0.6'
13
13
 
14
14
  gem 'codecov', '~> 0.6', require: false
15
15
  gem 'rubocop', '~> 1', require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack-ruby-block-kit (0.19.0)
4
+ slack-ruby-block-kit (0.21.0)
5
5
  zeitwerk (~> 2.6)
6
6
 
7
7
  GEM
@@ -14,7 +14,7 @@ GEM
14
14
  diff-lcs (1.5.0)
15
15
  docile (1.4.0)
16
16
  dotenv (2.8.1)
17
- faraday (1.10.2)
17
+ faraday (1.10.3)
18
18
  faraday-em_http (~> 1.0)
19
19
  faraday-em_synchrony (~> 1.0)
20
20
  faraday-excon (~> 1.1)
@@ -38,31 +38,31 @@ GEM
38
38
  faraday-rack (1.0.0)
39
39
  faraday-retry (1.0.3)
40
40
  method_source (1.0.0)
41
- multipart-post (2.2.3)
41
+ multipart-post (2.3.0)
42
42
  parallel (1.22.1)
43
43
  parser (3.1.2.0)
44
44
  ast (~> 2.4.1)
45
- pry (0.14.1)
45
+ pry (0.14.2)
46
46
  coderay (~> 1.1)
47
47
  method_source (~> 1.0)
48
48
  rainbow (3.1.1)
49
49
  rake (13.0.6)
50
50
  regexp_parser (2.3.1)
51
51
  rexml (3.2.5)
52
- rspec (3.11.0)
53
- rspec-core (~> 3.11.0)
54
- rspec-expectations (~> 3.11.0)
55
- rspec-mocks (~> 3.11.0)
56
- rspec-core (3.11.0)
57
- rspec-support (~> 3.11.0)
58
- rspec-expectations (3.11.0)
52
+ rspec (3.12.0)
53
+ rspec-core (~> 3.12.0)
54
+ rspec-expectations (~> 3.12.0)
55
+ rspec-mocks (~> 3.12.0)
56
+ rspec-core (3.12.0)
57
+ rspec-support (~> 3.12.0)
58
+ rspec-expectations (3.12.0)
59
59
  diff-lcs (>= 1.2.0, < 2.0)
60
- rspec-support (~> 3.11.0)
61
- rspec-mocks (3.11.0)
60
+ rspec-support (~> 3.12.0)
61
+ rspec-mocks (3.12.0)
62
62
  diff-lcs (>= 1.2.0, < 2.0)
63
- rspec-support (~> 3.11.0)
64
- rspec-support (3.11.0)
65
- rspec_junit_formatter (0.5.1)
63
+ rspec-support (~> 3.12.0)
64
+ rspec-support (3.12.0)
65
+ rspec_junit_formatter (0.6.0)
66
66
  rspec-core (>= 2, < 4, != 2.12.0)
67
67
  rubocop (1.28.2)
68
68
  parallel (~> 1.10)
@@ -88,7 +88,7 @@ GEM
88
88
  simplecov-html (0.12.3)
89
89
  simplecov_json_formatter (0.1.3)
90
90
  unicode-display_width (2.1.0)
91
- zeitwerk (2.6.0)
91
+ zeitwerk (2.6.7)
92
92
 
93
93
  PLATFORMS
94
94
  ruby
@@ -102,7 +102,7 @@ DEPENDENCIES
102
102
  pry (~> 0.14)
103
103
  rake (~> 13)
104
104
  rspec (~> 3)
105
- rspec_junit_formatter (~> 0.5)
105
+ rspec_junit_formatter (~> 0.6)
106
106
  rubocop (~> 1)
107
107
  rubocop-rake (~> 0.6)
108
108
  rubocop-rspec (~> 2)
@@ -17,10 +17,11 @@ module Slack
17
17
 
18
18
  TYPE = 'channels_select'
19
19
 
20
- def initialize(placeholder:, action_id:, initial: nil, emoji: nil)
20
+ def initialize(placeholder:, action_id:, initial: nil, emoji: nil, focus_on_load: nil)
21
21
  @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
22
22
  @action_id = action_id
23
23
  @initial_channel = initial
24
+ @focus_on_load = focus_on_load
24
25
 
25
26
  yield(self) if block_given?
26
27
  end
@@ -30,6 +31,7 @@ module Slack
30
31
  type: TYPE,
31
32
  placeholder: @placeholder.as_json,
32
33
  action_id: @action_id,
34
+ focus_on_load: @focus_on_load,
33
35
  initial_channel: @initial_channel,
34
36
  confirm: confirm&.as_json
35
37
  }.compact
@@ -12,8 +12,9 @@ module Slack
12
12
 
13
13
  TYPE = 'checkboxes'
14
14
 
15
- def initialize(action_id:)
15
+ def initialize(action_id:, focus_on_load: nil)
16
16
  @action_id = action_id
17
+ @focus_on_load = focus_on_load
17
18
  @options = []
18
19
 
19
20
  yield(self) if block_given?
@@ -36,6 +37,7 @@ module Slack
36
37
  action_id: @action_id,
37
38
  options: @options.map(&:as_json),
38
39
  initial_options: initial_options&.map(&:as_json),
40
+ focus_on_load: @focus_on_load,
39
41
  confirm: confirm&.as_json
40
42
  }.compact
41
43
  end
@@ -18,10 +18,17 @@ module Slack
18
18
 
19
19
  TYPE = 'conversations_select'
20
20
 
21
- def initialize(placeholder:, action_id:, initial: nil, emoji: nil)
21
+ def initialize(
22
+ placeholder:,
23
+ action_id:,
24
+ initial: nil,
25
+ emoji: nil,
26
+ focus_on_load: nil
27
+ )
22
28
  @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
23
29
  @action_id = action_id
24
30
  @initial_conversation = initial
31
+ @focus_on_load = focus_on_load
25
32
  @filter = nil
26
33
 
27
34
  yield(self) if block_given?
@@ -44,6 +51,7 @@ module Slack
44
51
  type: TYPE,
45
52
  placeholder: @placeholder.as_json,
46
53
  action_id: @action_id,
54
+ focus_on_load: @focus_on_load,
47
55
  initial_conversation: @initial_conversation,
48
56
  confirm: confirm&.as_json,
49
57
  filter: @filter&.as_json
@@ -14,9 +14,10 @@ module Slack
14
14
 
15
15
  TYPE = 'datepicker'
16
16
 
17
- def initialize(action_id:, placeholder: nil, initial: nil, emoji: nil)
17
+ def initialize(action_id:, placeholder: nil, initial: nil, emoji: nil, focus_on_load: nil)
18
18
  @action_id = action_id
19
19
  @initial_date = initial
20
+ @focus_on_load = focus_on_load
20
21
  @placeholder = placeholder_text(placeholder, emoji)
21
22
 
22
23
  yield(self) if block_given?
@@ -28,6 +29,7 @@ module Slack
28
29
  action_id: @action_id,
29
30
  placeholder: @placeholder&.as_json,
30
31
  initial_date: @initial_date,
32
+ focus_on_load: @focus_on_load,
31
33
  confirm: confirm&.as_json
32
34
  }.compact
33
35
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module BlockKit
5
+ module Element
6
+ # An element that allows the selection of both a date and a time of day
7
+ # formatted as a UNIX timestamp.
8
+ #
9
+ # On desktop clients, the time picker will take the form of a dropdown
10
+ # list and the date picker will take the form of a dropdown calendar.
11
+ # Both options will have free-text entry for precise choices. On mobile
12
+ # clients, the time picker and date picker will use native UIs.
13
+ #
14
+ # https://api.slack.com/reference/block-kit/block-elements#datetimepicker
15
+ class Datetimepicker
16
+ include Composition::ConfirmationDialog::Confirmable
17
+
18
+ TYPE = 'datetimepicker'
19
+
20
+ def initialize(action_id:, initial: nil, focus_on_load: nil)
21
+ @action_id = action_id
22
+ @initial_datetime = initial
23
+ @focus_on_load = focus_on_load
24
+
25
+ yield(self) if block_given?
26
+ end
27
+
28
+ def as_json(*)
29
+ {
30
+ type: TYPE,
31
+ action_id: @action_id,
32
+ initial_date_time: @initial_datetime,
33
+ focus_on_load: @focus_on_load,
34
+ confirm: confirm&.as_json
35
+ }.compact
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module BlockKit
5
+ module Element
6
+ # A Email input element, similar to the Plain-text input element, creates
7
+ # a single line field where a user can enter an email. It can appear as a
8
+ # single-line field.
9
+ #
10
+ # https://api.slack.com/reference/block-kit/block-elements#email
11
+ class EmailTextInput
12
+ TYPE = 'email_text_input'
13
+
14
+ def initialize(
15
+ action_id:,
16
+ placeholder: nil,
17
+ initial_value: nil,
18
+ focus_on_load: nil
19
+ )
20
+ @placeholder = placeholder && Composition::PlainText.new(text: placeholder)
21
+ @initial_value = initial_value
22
+ @action_id = action_id
23
+ @focus_on_load = focus_on_load
24
+ @dispatch_action_config = nil
25
+ end
26
+
27
+ def dispatch_action_config(triggers: nil)
28
+ @dispatch_action_config = Composition::DispatchActionConfiguration.new(triggers: triggers)
29
+
30
+ yield(@dispatch_action_config) if block_given?
31
+
32
+ self
33
+ end
34
+
35
+ def as_json(*)
36
+ {
37
+ type: TYPE,
38
+ action_id: @action_id,
39
+ placeholder: @placeholder&.as_json,
40
+ initial_value: @initial_value,
41
+ focus_on_load: @focus_on_load,
42
+ dispatch_action_config: @dispatch_action_config&.as_json
43
+ }.compact
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -23,11 +23,19 @@ module Slack
23
23
 
24
24
  TYPE = 'external_select'
25
25
 
26
- def initialize(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil)
26
+ def initialize(
27
+ placeholder:,
28
+ action_id:,
29
+ initial: nil,
30
+ min_query_length: nil,
31
+ emoji: nil,
32
+ focus_on_load: nil
33
+ )
27
34
  @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
28
35
  @action_id = action_id
29
36
  @initial_option = initial
30
37
  @min_query_length = min_query_length
38
+ @focus_on_load = focus_on_load
31
39
 
32
40
  yield(self) if block_given?
33
41
  end
@@ -37,6 +45,7 @@ module Slack
37
45
  type: TYPE,
38
46
  placeholder: @placeholder.as_json,
39
47
  action_id: @action_id,
48
+ focus_on_load: @focus_on_load,
40
49
  initial_option: @initial_option&.as_json,
41
50
  min_query_length: @min_query_length,
42
51
  confirm: confirm&.as_json
@@ -17,11 +17,19 @@ module Slack
17
17
 
18
18
  TYPE = 'multi_channels_select'
19
19
 
20
- def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
20
+ def initialize(
21
+ placeholder:,
22
+ action_id:,
23
+ initial: nil,
24
+ emoji: nil,
25
+ max_selected_items: nil,
26
+ focus_on_load: nil
27
+ )
21
28
  @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
22
29
  @action_id = action_id
23
30
  @initial_channels = initial
24
31
  @max_selected_items = max_selected_items
32
+ @focus_on_load = focus_on_load
25
33
 
26
34
  yield(self) if block_given?
27
35
  end
@@ -32,6 +40,7 @@ module Slack
32
40
  placeholder: @placeholder.as_json,
33
41
  action_id: @action_id,
34
42
  initial_channels: @initial_channels,
43
+ focus_on_load: @focus_on_load,
35
44
  confirm: confirm&.as_json,
36
45
  max_selected_items: @max_selected_items
37
46
  }.compact
@@ -18,11 +18,19 @@ module Slack
18
18
 
19
19
  TYPE = 'multi_conversations_select'
20
20
 
21
- def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
21
+ def initialize(
22
+ placeholder:,
23
+ action_id:,
24
+ initial: nil,
25
+ emoji: nil,
26
+ max_selected_items: nil,
27
+ focus_on_load: nil
28
+ )
22
29
  @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
23
30
  @action_id = action_id
24
31
  @initial_conversations = initial
25
32
  @max_selected_items = max_selected_items
33
+ @focus_on_load = focus_on_load
26
34
  @filter = nil
27
35
 
28
36
  yield(self) if block_given?
@@ -46,6 +54,7 @@ module Slack
46
54
  placeholder: @placeholder.as_json,
47
55
  action_id: @action_id,
48
56
  initial_conversations: @initial_conversations,
57
+ focus_on_load: @focus_on_load,
49
58
  confirm: confirm&.as_json,
50
59
  max_selected_items: @max_selected_items,
51
60
  filter: @filter&.as_json
@@ -23,14 +23,21 @@ module Slack
23
23
 
24
24
  TYPE = 'multi_external_select'
25
25
 
26
- def initialize(placeholder:, action_id:,
27
- initial: nil, min_query_length: nil, emoji: nil, max_selected_items: nil)
28
-
26
+ def initialize(
27
+ placeholder:,
28
+ action_id:,
29
+ initial: nil,
30
+ min_query_length: nil,
31
+ emoji: nil,
32
+ max_selected_items: nil,
33
+ focus_on_load: nil
34
+ )
29
35
  @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
30
36
  @action_id = action_id
31
37
  @initial_options = initial
32
38
  @min_query_length = min_query_length
33
39
  @max_selected_items = max_selected_items
40
+ @focus_on_load = focus_on_load
34
41
 
35
42
  yield(self) if block_given?
36
43
  end
@@ -40,6 +47,7 @@ module Slack
40
47
  type: TYPE,
41
48
  placeholder: @placeholder.as_json,
42
49
  action_id: @action_id,
50
+ focus_on_load: @focus_on_load,
43
51
  initial_options: @initial_options&.map(&:as_json),
44
52
  min_query_length: @min_query_length,
45
53
  confirm: confirm&.as_json,
@@ -19,10 +19,17 @@ module Slack
19
19
 
20
20
  attr_accessor :options, :option_groups
21
21
 
22
- def initialize(placeholder:, action_id:, emoji: nil, max_selected_items: nil)
22
+ def initialize(
23
+ placeholder:,
24
+ action_id:,
25
+ emoji: nil,
26
+ max_selected_items: nil,
27
+ focus_on_load: nil
28
+ )
23
29
  @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
24
30
  @action_id = action_id
25
31
  @max_selected_items = max_selected_items
32
+ @focus_on_load = focus_on_load
26
33
 
27
34
  @options = nil
28
35
  @option_groups = nil
@@ -58,6 +65,7 @@ module Slack
58
65
  type: TYPE,
59
66
  placeholder: @placeholder.as_json,
60
67
  action_id: @action_id,
68
+ focus_on_load: @focus_on_load,
61
69
  options: @options&.map(&:as_json),
62
70
  option_groups: @option_groups&.map(&:as_json),
63
71
  initial_options: initial_options&.map(&:as_json),
@@ -17,11 +17,19 @@ module Slack
17
17
 
18
18
  TYPE = 'multi_users_select'
19
19
 
20
- def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
20
+ def initialize(
21
+ placeholder:,
22
+ action_id:,
23
+ initial: nil,
24
+ emoji: nil,
25
+ max_selected_items: nil,
26
+ focus_on_load: nil
27
+ )
21
28
  @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
22
29
  @action_id = action_id
23
30
  @initial_users = initial
24
31
  @max_selected_items = max_selected_items
32
+ @focus_on_load = focus_on_load
25
33
 
26
34
  yield(self) if block_given?
27
35
  end
@@ -32,6 +40,7 @@ module Slack
32
40
  placeholder: @placeholder.as_json,
33
41
  action_id: @action_id,
34
42
  initial_users: @initial_users,
43
+ focus_on_load: @focus_on_load,
35
44
  confirm: confirm&.as_json,
36
45
  max_selected_items: @max_selected_items
37
46
  }.compact
@@ -20,7 +20,8 @@ module Slack
20
20
  initial_value: nil,
21
21
  multiline: nil,
22
22
  min_length: nil,
23
- max_length: nil
23
+ max_length: nil,
24
+ focus_on_load: nil
24
25
  )
25
26
  @placeholder = placeholder && Composition::PlainText.new(text: placeholder, emoji: emoji)
26
27
  @initial_value = initial_value
@@ -28,6 +29,7 @@ module Slack
28
29
  @multiline = multiline
29
30
  @min_length = min_length
30
31
  @max_length = max_length
32
+ @focus_on_load = focus_on_load
31
33
  @dispatch_action_config = nil
32
34
  end
33
35
 
@@ -48,6 +50,7 @@ module Slack
48
50
  min_length: @min_length,
49
51
  max_length: @max_length,
50
52
  initial_value: @initial_value,
53
+ focus_on_load: @focus_on_load,
51
54
  dispatch_action_config: @dispatch_action_config&.as_json
52
55
  }.compact
53
56
  end
@@ -13,8 +13,9 @@ module Slack
13
13
 
14
14
  attr_accessor :options
15
15
 
16
- def initialize(action_id:)
16
+ def initialize(action_id:, focus_on_load: nil)
17
17
  @action_id = action_id
18
+ @focus_on_load = focus_on_load
18
19
  @options = []
19
20
 
20
21
  yield(self) if block_given?
@@ -36,6 +37,7 @@ module Slack
36
37
  {
37
38
  type: TYPE,
38
39
  action_id: @action_id,
40
+ focus_on_load: @focus_on_load,
39
41
  options: @options.map(&:as_json),
40
42
  initial_option: initial_option&.as_json,
41
43
  confirm: confirm&.as_json
@@ -19,9 +19,10 @@ module Slack
19
19
 
20
20
  attr_accessor :options, :option_groups
21
21
 
22
- def initialize(placeholder:, action_id:, emoji: nil)
22
+ def initialize(placeholder:, action_id:, emoji: nil, focus_on_load: nil)
23
23
  @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
24
24
  @action_id = action_id
25
+ @focus_on_load = focus_on_load
25
26
 
26
27
  yield(self) if block_given?
27
28
  end
@@ -54,6 +55,7 @@ module Slack
54
55
  type: TYPE,
55
56
  placeholder: @placeholder.as_json,
56
57
  action_id: @action_id,
58
+ focus_on_load: @focus_on_load,
57
59
  options: options&.map(&:as_json),
58
60
  option_groups: option_groups&.map(&:as_json),
59
61
  initial_option: initial_option&.as_json,
@@ -15,10 +15,11 @@ module Slack
15
15
 
16
16
  TYPE = 'timepicker'
17
17
 
18
- def initialize(action_id:, placeholder: nil, initial: nil, emoji: nil)
18
+ def initialize(action_id:, placeholder: nil, initial: nil, emoji: nil, focus_on_load: nil)
19
19
  @placeholder = placeholder_text(placeholder, emoji) if placeholder
20
20
  @initial_time = initial
21
21
  @action_id = action_id
22
+ @focus_on_load = focus_on_load
22
23
 
23
24
  yield(self) if block_given?
24
25
  end
@@ -29,6 +30,7 @@ module Slack
29
30
  action_id: @action_id,
30
31
  placeholder: @placeholder&.as_json,
31
32
  initial_time: @initial_time,
33
+ focus_on_load: @focus_on_load,
32
34
  confirm: confirm&.as_json
33
35
  }.compact
34
36
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module BlockKit
5
+ module Element
6
+ # A URL input element, similar to the Plain-text input element, creates a single line field where a user can
7
+ # enter a URL. It can appear as a single-line field.
8
+ #
9
+ # URL-text input elements are currently only available in modals
10
+ #
11
+ # https://api.slack.com/reference/block-kit/block-elements#url
12
+ class UrlTextInput
13
+ TYPE = 'url_text_input'
14
+
15
+ def initialize(
16
+ action_id:,
17
+ placeholder: nil,
18
+ initial_value: nil,
19
+ focus_on_load: nil
20
+ )
21
+ @placeholder = placeholder && Composition::PlainText.new(text: placeholder)
22
+ @initial_value = initial_value
23
+ @action_id = action_id
24
+ @focus_on_load = focus_on_load
25
+ @dispatch_action_config = nil
26
+ end
27
+
28
+ def dispatch_action_config(triggers: nil)
29
+ @dispatch_action_config = Composition::DispatchActionConfiguration.new(triggers: triggers)
30
+
31
+ yield(@dispatch_action_config) if block_given?
32
+
33
+ self
34
+ end
35
+
36
+ def as_json(*)
37
+ {
38
+ type: TYPE,
39
+ action_id: @action_id,
40
+ placeholder: @placeholder&.as_json,
41
+ initial_value: @initial_value,
42
+ focus_on_load: @focus_on_load,
43
+ dispatch_action_config: @dispatch_action_config&.as_json
44
+ }.compact
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -17,10 +17,11 @@ module Slack
17
17
 
18
18
  TYPE = 'users_select'
19
19
 
20
- def initialize(placeholder:, action_id:, initial: nil, emoji: nil)
20
+ def initialize(placeholder:, action_id:, initial: nil, emoji: nil, focus_on_load: nil)
21
21
  @placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
22
22
  @action_id = action_id
23
23
  @initial_user = initial
24
+ @focus_on_load = focus_on_load
24
25
 
25
26
  yield(self) if block_given?
26
27
  end
@@ -30,6 +31,7 @@ module Slack
30
31
  type: TYPE,
31
32
  placeholder: @placeholder.as_json,
32
33
  action_id: @action_id,
34
+ focus_on_load: @focus_on_load,
33
35
  initial_user: @initial_user,
34
36
  confirm: confirm&.as_json
35
37
  }.compact
@@ -8,7 +8,7 @@ module Slack
8
8
  # a select menu element, a multi-select menu element, or a datepicker.
9
9
  #
10
10
  # https://api.slack.com/reference/block-kit/blocks#input
11
- class Input
11
+ class Input # rubocop:disable Metrics/ClassLength
12
12
  TYPE = 'input'
13
13
 
14
14
  attr_accessor :label, :element, :block_id, :hint, :optional, :emoji
@@ -104,6 +104,17 @@ module Slack
104
104
  self
105
105
  end
106
106
 
107
+ def datetimepicker(action_id:, initial: nil)
108
+ @element = Element::Datetimepicker.new(
109
+ action_id: action_id,
110
+ initial: initial
111
+ )
112
+
113
+ yield(@element) if block_given?
114
+
115
+ self
116
+ end
117
+
107
118
  def multi_channels_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
108
119
  @element = Element::MultiChannelsSelect.new(
109
120
  placeholder: placeholder,
@@ -201,6 +212,34 @@ module Slack
201
212
  self
202
213
  end
203
214
 
215
+ def url_text_input(
216
+ action_id:,
217
+ placeholder: nil,
218
+ initial_value: nil,
219
+ focus_on_load: nil
220
+ )
221
+ @element = Element::UrlTextInput.new(
222
+ action_id: action_id,
223
+ placeholder: placeholder,
224
+ initial_value: initial_value,
225
+ focus_on_load: focus_on_load
226
+ )
227
+ end
228
+
229
+ def email_text_input(
230
+ action_id:,
231
+ placeholder: nil,
232
+ initial_value: nil,
233
+ focus_on_load: nil
234
+ )
235
+ @element = Element::EmailTextInput.new(
236
+ action_id: action_id,
237
+ placeholder: placeholder,
238
+ initial_value: initial_value,
239
+ focus_on_load: focus_on_load
240
+ )
241
+ end
242
+
204
243
  def radio_buttons(action_id:)
205
244
  @element = Element::RadioButtons.new(action_id: action_id)
206
245
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Slack
4
4
  module BlockKit
5
- VERSION = '0.19.0'
5
+ VERSION = '0.21.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-block-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Gregg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-05 00:00:00.000000000 Z
11
+ date: 2023-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -61,6 +61,8 @@ files:
61
61
  - lib/slack/block_kit/element/checkboxes.rb
62
62
  - lib/slack/block_kit/element/conversations_select.rb
63
63
  - lib/slack/block_kit/element/datepicker.rb
64
+ - lib/slack/block_kit/element/datetimepicker.rb
65
+ - lib/slack/block_kit/element/email_text_input.rb
64
66
  - lib/slack/block_kit/element/external_select.rb
65
67
  - lib/slack/block_kit/element/image.rb
66
68
  - lib/slack/block_kit/element/multi_channels_select.rb
@@ -73,6 +75,7 @@ files:
73
75
  - lib/slack/block_kit/element/radio_buttons.rb
74
76
  - lib/slack/block_kit/element/static_select.rb
75
77
  - lib/slack/block_kit/element/timepicker.rb
78
+ - lib/slack/block_kit/element/url_text_input.rb
76
79
  - lib/slack/block_kit/element/users_select.rb
77
80
  - lib/slack/block_kit/formatting.rb
78
81
  - lib/slack/block_kit/layout/actions.rb
@@ -112,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
115
  - !ruby/object:Gem::Version
113
116
  version: '0'
114
117
  requirements: []
115
- rubygems_version: 3.3.21
118
+ rubygems_version: 3.4.7
116
119
  signing_key:
117
120
  specification_version: 4
118
121
  summary: A ruby wrapper for Slack's Block Kit