slack_valid_block_kit 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8a63ed2dae6658d4937921060031910bdbffbf23182caee0416e06a63e202d3
|
4
|
+
data.tar.gz: 06041afc62ab5d6383660e16e63fc4b714fb0b376164e2228861caef8b6ab87e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efa130469a2b3da6f0d8af1c3b6c6e3019adeb87ee94e54bc0cd9e028efab6e070e86031dbea1cbab8d290b85d7a677348c08dc0a421d06c06cd965531b82ca7
|
7
|
+
data.tar.gz: f766653a8f07483397a47ac6bab6f711be9a22246058d3b784fd7a2b9c2ff0dced5441cf45158be9295ae1f1ed144aba5c61a494c1b390b651170951563e05f1
|
@@ -1,10 +1,12 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
1
3
|
module SlackValidBlockKit
|
2
4
|
module Builder
|
3
5
|
module Elements
|
4
6
|
def button(text:, action_id:, url: nil, value: nil, style: nil, confirm: nil, accessibility_label: nil)
|
5
7
|
hash = { type: 'button' }
|
6
8
|
hash[:text] = text
|
7
|
-
hash[:action_id] = action_id
|
9
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
8
10
|
hash[:url] = url unless url.nil?
|
9
11
|
hash[:value] = value unless value.nil?
|
10
12
|
hash[:style] = style unless style.nil?
|
@@ -15,7 +17,7 @@ module SlackValidBlockKit
|
|
15
17
|
|
16
18
|
def checkboxes(action_id:, options:, initial_options: nil, confirm: nil, focus_on_load: nil)
|
17
19
|
hash = { type: 'checkboxes' }
|
18
|
-
hash[:action_id] = action_id
|
20
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
19
21
|
hash[:options] = options
|
20
22
|
hash[:initial_options] = initial_options unless initial_options.nil?
|
21
23
|
hash[:confirm] = confirm unless confirm.nil?
|
@@ -25,9 +27,17 @@ module SlackValidBlockKit
|
|
25
27
|
|
26
28
|
def datepicker(action_id:, placeholder: nil, initial_date: nil, confirm: nil, focus_on_load: nil)
|
27
29
|
hash = { type: 'datepicker' }
|
28
|
-
hash[:action_id] = action_id
|
30
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
29
31
|
hash[:placeholder] = placeholder unless placeholder.nil?
|
30
|
-
|
32
|
+
unless initial_date.nil?
|
33
|
+
if initial_date.is_a?(Date)
|
34
|
+
hash[:initial_date] = initial_date.to_s
|
35
|
+
elsif initial_date.is_a?(Time)
|
36
|
+
hash[:initial_date] = initial_date.to_date.to_s
|
37
|
+
else
|
38
|
+
hash[:initial_date] = initial_date
|
39
|
+
end
|
40
|
+
end
|
31
41
|
hash[:confirm] = confirm unless confirm.nil?
|
32
42
|
hash[:focus_on_load] = focus_on_load unless focus_on_load.nil?
|
33
43
|
hash
|
@@ -43,7 +53,7 @@ module SlackValidBlockKit
|
|
43
53
|
def multi_static_select(placeholder:, action_id:, options:, option_groups: nil, initial_options: nil, confirm: nil, max_selected_items: nil, focus_on_load: nil)
|
44
54
|
hash = { type: 'multi_static_select' }
|
45
55
|
hash[:placeholder] = placeholder
|
46
|
-
hash[:action_id] = action_id
|
56
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
47
57
|
hash[:options] = options
|
48
58
|
hash[:option_groups] = option_groups unless option_groups.nil?
|
49
59
|
hash[:initial_options] = initial_options unless initial_options.nil?
|
@@ -56,7 +66,7 @@ module SlackValidBlockKit
|
|
56
66
|
def multi_external_select(placeholder:, action_id:, min_query_length: nil, initial_options: nil, confirm: nil, max_selected_items: nil, focus_on_load: nil)
|
57
67
|
hash = { type: 'multi_external_select' }
|
58
68
|
hash[:placeholder] = placeholder
|
59
|
-
hash[:action_id] = action_id
|
69
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
60
70
|
hash[:min_query_length] = min_query_length unless min_query_length.nil?
|
61
71
|
hash[:initial_options] = initial_options unless initial_options.nil?
|
62
72
|
hash[:confirm] = confirm unless confirm.nil?
|
@@ -68,7 +78,7 @@ module SlackValidBlockKit
|
|
68
78
|
def multi_users_select(placeholder:, action_id:, initial_users: nil, confirm: nil, max_selected_items: nil, focus_on_load: nil)
|
69
79
|
hash = { type: 'multi_users_select' }
|
70
80
|
hash[:placeholder] = placeholder
|
71
|
-
hash[:action_id] = action_id
|
81
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
72
82
|
hash[:initial_users] = initial_users unless initial_users.nil?
|
73
83
|
hash[:confirm] = confirm unless confirm.nil?
|
74
84
|
hash[:max_selected_items] = max_selected_items unless max_selected_items.nil?
|
@@ -79,7 +89,7 @@ module SlackValidBlockKit
|
|
79
89
|
def multi_conversations_select(placeholder:, action_id:, initial_conversations: nil, default_to_current_conversation: nil, confirm: nil, max_selected_items: nil, filter: nil, focus_on_load: nil)
|
80
90
|
hash = { type: 'multi_conversations_select' }
|
81
91
|
hash[:placeholder] = placeholder
|
82
|
-
hash[:action_id] = action_id
|
92
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
83
93
|
hash[:initial_conversations] = initial_conversations unless initial_conversations.nil?
|
84
94
|
hash[:default_to_current_conversation] = default_to_current_conversation unless default_to_current_conversation.nil?
|
85
95
|
hash[:confirm] = confirm unless confirm.nil?
|
@@ -92,7 +102,7 @@ module SlackValidBlockKit
|
|
92
102
|
def multi_channels_select(placeholder:, action_id:, initial_channels: nil, confirm: nil, max_selected_items: nil, focus_on_load: nil)
|
93
103
|
hash = { type: 'multi_channels_select' }
|
94
104
|
hash[:placeholder] = placeholder
|
95
|
-
hash[:action_id] = action_id
|
105
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
96
106
|
hash[:initial_channels] = initial_channels unless initial_channels.nil?
|
97
107
|
hash[:confirm] = confirm unless confirm.nil?
|
98
108
|
hash[:max_selected_items] = max_selected_items unless max_selected_items.nil?
|
@@ -103,14 +113,14 @@ module SlackValidBlockKit
|
|
103
113
|
def overflow(options:, action_id:, confirm: nil)
|
104
114
|
hash = { type: 'overflow' }
|
105
115
|
hash[:options] = options
|
106
|
-
hash[:action_id] = action_id
|
116
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
107
117
|
hash[:confirm] = confirm unless confirm.nil?
|
108
118
|
hash
|
109
119
|
end
|
110
120
|
|
111
121
|
def plain_text_input(action_id:, placeholder: nil, initial_value: nil, multiline: nil, min_length: nil, max_length: nil, dispatch_action_config: nil, focus_on_load: nil)
|
112
122
|
hash = { type: 'plain_text_input' }
|
113
|
-
hash[:action_id] = action_id
|
123
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
114
124
|
hash[:placeholder] = placeholder unless placeholder.nil?
|
115
125
|
hash[:initial_value] = initial_value unless initial_value.nil?
|
116
126
|
hash[:multiline] = multiline unless multiline.nil?
|
@@ -124,7 +134,7 @@ module SlackValidBlockKit
|
|
124
134
|
def radio_buttons(options:, action_id:, initial_option: nil, confirm: nil, focus_on_load: nil)
|
125
135
|
hash = { type: 'radio_buttons' }
|
126
136
|
hash[:options] = options
|
127
|
-
hash[:action_id] = action_id
|
137
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
128
138
|
hash[:initial_option] = initial_option unless initial_option.nil?
|
129
139
|
hash[:confirm] = confirm unless confirm.nil?
|
130
140
|
hash[:focus_on_load] = focus_on_load unless focus_on_load.nil?
|
@@ -134,7 +144,7 @@ module SlackValidBlockKit
|
|
134
144
|
def static_select(placeholder:, action_id:, options:, option_groups: nil, initial_option: nil, confirm: nil, focus_on_load: nil)
|
135
145
|
hash = { type: 'static_select' }
|
136
146
|
hash[:placeholder] = placeholder
|
137
|
-
hash[:action_id] = action_id
|
147
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
138
148
|
hash[:options] = options
|
139
149
|
hash[:option_groups] = option_groups unless option_groups.nil?
|
140
150
|
hash[:initial_option] = initial_option unless initial_option.nil?
|
@@ -146,7 +156,7 @@ module SlackValidBlockKit
|
|
146
156
|
def external_select(placeholder:, action_id:, min_query_length: nil, initial_option: nil, confirm: nil, focus_on_load: nil)
|
147
157
|
hash = { type: 'external_select' }
|
148
158
|
hash[:placeholder] = placeholder
|
149
|
-
hash[:action_id] = action_id
|
159
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
150
160
|
hash[:min_query_length] = min_query_length unless min_query_length.nil?
|
151
161
|
hash[:initial_option] = initial_option unless initial_option.nil?
|
152
162
|
hash[:confirm] = confirm unless confirm.nil?
|
@@ -157,7 +167,7 @@ module SlackValidBlockKit
|
|
157
167
|
def users_select(placeholder:, action_id:, initial_user: nil, confirm: nil, focus_on_load: nil)
|
158
168
|
hash = { type: 'users_select' }
|
159
169
|
hash[:placeholder] = placeholder
|
160
|
-
hash[:action_id] = action_id
|
170
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
161
171
|
hash[:initial_user] = initial_user unless initial_user.nil?
|
162
172
|
hash[:confirm] = confirm unless confirm.nil?
|
163
173
|
hash[:focus_on_load] = focus_on_load unless focus_on_load.nil?
|
@@ -167,7 +177,7 @@ module SlackValidBlockKit
|
|
167
177
|
def conversations_select(placeholder:, action_id:, initial_conversation: nil, default_to_current_conversation: nil, confirm: nil, response_url_enabled: nil, filter: nil, focus_on_load: nil)
|
168
178
|
hash = { type: 'conversations_select' }
|
169
179
|
hash[:placeholder] = placeholder
|
170
|
-
hash[:action_id] = action_id
|
180
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
171
181
|
hash[:initial_conversation] = initial_conversation unless initial_conversation.nil?
|
172
182
|
hash[:default_to_current_conversation] = default_to_current_conversation unless default_to_current_conversation.nil?
|
173
183
|
hash[:confirm] = confirm unless confirm.nil?
|
@@ -180,7 +190,7 @@ module SlackValidBlockKit
|
|
180
190
|
def channels_select(placeholder:, action_id:, initial_channel: nil, confirm: nil, response_url_enabled: nil, focus_on_load: nil)
|
181
191
|
hash = { type: 'channels_select' }
|
182
192
|
hash[:placeholder] = placeholder
|
183
|
-
hash[:action_id] = action_id
|
193
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
184
194
|
hash[:initial_channel] = initial_channel unless initial_channel.nil?
|
185
195
|
hash[:confirm] = confirm unless confirm.nil?
|
186
196
|
hash[:response_url_enabled] = response_url_enabled unless response_url_enabled.nil?
|
@@ -190,9 +200,15 @@ module SlackValidBlockKit
|
|
190
200
|
|
191
201
|
def timepicker(action_id:, placeholder: nil, initial_time: nil, confirm: nil, focus_on_load: nil)
|
192
202
|
hash = { type: 'timepicker' }
|
193
|
-
hash[:action_id] = action_id
|
203
|
+
hash[:action_id] = action_id.is_a?(Symbol) ? action_id.to_s : action_id
|
194
204
|
hash[:placeholder] = placeholder unless placeholder.nil?
|
195
|
-
|
205
|
+
unless initial_time.nil?
|
206
|
+
if initial_time.is_a?(Time)
|
207
|
+
hash[:initial_time] = initial_time.strftime("%H:%M")
|
208
|
+
else
|
209
|
+
hash[:initial_time] = initial_time
|
210
|
+
end
|
211
|
+
end
|
196
212
|
hash[:confirm] = confirm unless confirm.nil?
|
197
213
|
hash[:focus_on_load] = focus_on_load unless focus_on_load.nil?
|
198
214
|
hash
|
@@ -4,20 +4,20 @@ module SlackValidBlockKit
|
|
4
4
|
def actions(elements:, block_id: nil)
|
5
5
|
hash = { type: 'actions' }
|
6
6
|
hash[:elements] = elements
|
7
|
-
hash[:block_id] = block_id unless block_id.nil?
|
7
|
+
hash[:block_id] = block_id.is_a?(Symbol) ? block_id.to_s : block_id unless block_id.nil?
|
8
8
|
hash
|
9
9
|
end
|
10
10
|
|
11
11
|
def context(elements:, block_id: nil)
|
12
12
|
hash = { type: 'context' }
|
13
13
|
hash[:elements] = elements
|
14
|
-
hash[:block_id] = block_id unless block_id.nil?
|
14
|
+
hash[:block_id] = block_id.is_a?(Symbol) ? block_id.to_s : block_id unless block_id.nil?
|
15
15
|
hash
|
16
16
|
end
|
17
17
|
|
18
18
|
def divider(block_id: nil)
|
19
19
|
hash = { type: 'divider' }
|
20
|
-
hash[:block_id] = block_id unless block_id.nil?
|
20
|
+
hash[:block_id] = block_id.is_a?(Symbol) ? block_id.to_s : block_id unless block_id.nil?
|
21
21
|
hash
|
22
22
|
end
|
23
23
|
|
@@ -25,14 +25,14 @@ module SlackValidBlockKit
|
|
25
25
|
hash = { type: 'file' }
|
26
26
|
hash[:elements] = elements
|
27
27
|
hash[:source] = source
|
28
|
-
hash[:block_id] = block_id unless block_id.nil?
|
28
|
+
hash[:block_id] = block_id.is_a?(Symbol) ? block_id.to_s : block_id unless block_id.nil?
|
29
29
|
hash
|
30
30
|
end
|
31
31
|
|
32
32
|
def header(text:, block_id: nil)
|
33
33
|
hash = { type: 'header' }
|
34
34
|
hash[:text] = text
|
35
|
-
hash[:block_id] = block_id unless block_id.nil?
|
35
|
+
hash[:block_id] = block_id.is_a?(Symbol) ? block_id.to_s : block_id unless block_id.nil?
|
36
36
|
hash
|
37
37
|
end
|
38
38
|
|
@@ -41,7 +41,7 @@ module SlackValidBlockKit
|
|
41
41
|
hash[:image_url] = image_url
|
42
42
|
hash[:alt_text] = alt_text
|
43
43
|
hash[:title] = title unless title.nil?
|
44
|
-
hash[:block_id] = block_id unless block_id.nil?
|
44
|
+
hash[:block_id] = block_id.is_a?(Symbol) ? block_id.to_s : block_id unless block_id.nil?
|
45
45
|
hash
|
46
46
|
end
|
47
47
|
|
@@ -50,7 +50,7 @@ module SlackValidBlockKit
|
|
50
50
|
hash[:label] = label
|
51
51
|
hash[:element] = element
|
52
52
|
hash[:dispatch_action] = dispatch_action unless dispatch_action.nil?
|
53
|
-
hash[:block_id] = block_id unless block_id.nil?
|
53
|
+
hash[:block_id] = block_id.is_a?(Symbol) ? block_id.to_s : block_id unless block_id.nil?
|
54
54
|
hash[:hint] = hint unless hint.nil?
|
55
55
|
hash[:optional] = optional unless optional.nil?
|
56
56
|
hash
|
@@ -59,7 +59,7 @@ module SlackValidBlockKit
|
|
59
59
|
def section(text: nil, block_id: nil, fields: nil, accessory: nil)
|
60
60
|
hash = { type: 'section' }
|
61
61
|
hash[:text] = text unless text.nil?
|
62
|
-
hash[:block_id] = block_id unless block_id.nil?
|
62
|
+
hash[:block_id] = block_id.is_a?(Symbol) ? block_id.to_s : block_id unless block_id.nil?
|
63
63
|
hash[:fields] = fields unless fields.nil?
|
64
64
|
hash[:accessory] = accessory unless accessory.nil?
|
65
65
|
hash
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_valid_block_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masayuki-ioki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|