Class: Slack::BlockKit::Layout::Input
- Inherits:
-
Object
- Object
- Slack::BlockKit::Layout::Input
- Defined in:
- lib/slack/block_kit/layout/input.rb
Overview
A block that collects information from users - it can hold a plain-text input element, a checkbox element, a radio button element, a select menu element, a multi-select menu element, or a datepicker.
Constant Summary collapse
- TYPE =
rubocop:disable Metrics/ClassLength
'input'
Instance Attribute Summary collapse
-
#block_id ⇒ Object
Returns the value of attribute block_id.
-
#element ⇒ Object
Returns the value of attribute element.
-
#emoji ⇒ Object
Returns the value of attribute emoji.
-
#hint ⇒ Object
Returns the value of attribute hint.
-
#label ⇒ Object
Returns the value of attribute label.
-
#optional ⇒ Object
Returns the value of attribute optional.
Instance Method Summary collapse
- #as_json ⇒ Object
- #channels_select(placeholder:, action_id:, initial: nil, emoji: nil, response_url_enabled: nil) {|@element| ... } ⇒ Object
- #checkboxes(action_id:) {|@element| ... } ⇒ Object
- #conversation_select(placeholder:, action_id:, initial: nil, emoji: nil, default_to_current_conversation: nil, response_url_enabled: nil) {|@element| ... } ⇒ Object
- #datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) {|@element| ... } ⇒ Object
- #datetimepicker(action_id:, initial: nil) {|@element| ... } ⇒ Object
- #email_text_input(action_id:, placeholder: nil, initial_value: nil, focus_on_load: nil) ⇒ Object
- #external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil) {|@element| ... } ⇒ Object
-
#initialize(label:, element: nil, block_id: nil, hint: nil, optional: nil, emoji: nil, dispatch_action: nil) ⇒ Input
constructor
A new instance of Input.
- #multi_channels_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil) {|@element| ... } ⇒ Object
- #multi_conversations_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil, default_to_current_conversation: nil) {|@element| ... } ⇒ Object
- #multi_external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil, max_selected_items: nil) {|@element| ... } ⇒ Object
- #multi_static_select(placeholder:, action_id:, emoji: nil, max_selected_items: nil) {|@element| ... } ⇒ Object
- #multi_users_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil) {|@element| ... } ⇒ Object
- #plain_text_input(action_id:, placeholder: nil, emoji: nil, initial_value: nil, multiline: nil, min_length: nil, max_length: nil) ⇒ Object
- #radio_buttons(action_id:) {|@element| ... } ⇒ Object
- #static_select(placeholder:, action_id:, emoji: nil) {|@element| ... } ⇒ Object
- #timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) {|@element| ... } ⇒ Object
- #url_text_input(action_id:, placeholder: nil, initial_value: nil, focus_on_load: nil) ⇒ Object
- #users_select(placeholder:, action_id:, initial: nil, emoji: nil) {|@element| ... } ⇒ Object
Constructor Details
#initialize(label:, element: nil, block_id: nil, hint: nil, optional: nil, emoji: nil, dispatch_action: nil) ⇒ Input
Returns a new instance of Input.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/slack/block_kit/layout/input.rb', line 16 def initialize( label:, element: nil, block_id: nil, hint: nil, optional: nil, emoji: nil, dispatch_action: 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 @dispatch_action = dispatch_action end |
Instance Attribute Details
#block_id ⇒ Object
Returns the value of attribute block_id.
14 15 16 |
# File 'lib/slack/block_kit/layout/input.rb', line 14 def block_id @block_id end |
#element ⇒ Object
Returns the value of attribute element.
14 15 16 |
# File 'lib/slack/block_kit/layout/input.rb', line 14 def element @element end |
#emoji ⇒ Object
Returns the value of attribute emoji.
14 15 16 |
# File 'lib/slack/block_kit/layout/input.rb', line 14 def emoji @emoji end |
#hint ⇒ Object
Returns the value of attribute hint.
14 15 16 |
# File 'lib/slack/block_kit/layout/input.rb', line 14 def hint @hint end |
#label ⇒ Object
Returns the value of attribute label.
14 15 16 |
# File 'lib/slack/block_kit/layout/input.rb', line 14 def label @label end |
#optional ⇒ Object
Returns the value of attribute optional.
14 15 16 |
# File 'lib/slack/block_kit/layout/input.rb', line 14 def optional @optional end |
Instance Method Details
#as_json ⇒ Object
282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/slack/block_kit/layout/input.rb', line 282 def as_json(*) { type: TYPE, element: @element.as_json, label: @label&.as_json, hint: @hint&.as_json, block_id: @block_id, optional: optional, dispatch_action: @dispatch_action }.compact end |
#channels_select(placeholder:, action_id:, initial: nil, emoji: nil, response_url_enabled: nil) {|@element| ... } ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/slack/block_kit/layout/input.rb', line 63 def channels_select(placeholder:, action_id:, initial: nil, emoji: nil, response_url_enabled: nil) @element = Element::ChannelsSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji, response_url_enabled: response_url_enabled ) yield(@element) if block_given? self end |
#checkboxes(action_id:) {|@element| ... } ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/slack/block_kit/layout/input.rb', line 77 def checkboxes(action_id:) @element = Element::Checkboxes.new(action_id: action_id) yield(@element) if block_given? self end |
#conversation_select(placeholder:, action_id:, initial: nil, emoji: nil, default_to_current_conversation: nil, response_url_enabled: nil) {|@element| ... } ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/slack/block_kit/layout/input.rb', line 33 def conversation_select(placeholder:, action_id:, initial: nil, emoji: nil, default_to_current_conversation: nil, response_url_enabled: nil) @element = Element::ConversationsSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji, default_to_current_conversation: default_to_current_conversation, response_url_enabled: response_url_enabled ) yield(@element) if block_given? self end |
#datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) {|@element| ... } ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/slack/block_kit/layout/input.rb', line 85 def datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) @element = Element::Datepicker.new( action_id: action_id, placeholder: placeholder, initial: initial, emoji: emoji ) yield(@element) if block_given? self end |
#datetimepicker(action_id:, initial: nil) {|@element| ... } ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/slack/block_kit/layout/input.rb', line 111 def datetimepicker(action_id:, initial: nil) @element = Element::Datetimepicker.new( action_id: action_id, initial: initial ) yield(@element) if block_given? self end |
#email_text_input(action_id:, placeholder: nil, initial_value: nil, focus_on_load: nil) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/slack/block_kit/layout/input.rb', line 233 def email_text_input( action_id:, placeholder: nil, initial_value: nil, focus_on_load: nil ) @element = Element::EmailTextInput.new( action_id: action_id, placeholder: placeholder, initial_value: initial_value, focus_on_load: focus_on_load ) end |
#external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil) {|@element| ... } ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/slack/block_kit/layout/input.rb', line 161 def external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil) @element = Element::ExternalSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, min_query_length: min_query_length, emoji: emoji ) yield(@element) if block_given? self end |
#multi_channels_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil) {|@element| ... } ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/slack/block_kit/layout/input.rb', line 122 def multi_channels_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil) @element = Element::MultiChannelsSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji, max_selected_items: max_selected_items ) yield(@element) if block_given? self end |
#multi_conversations_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil, default_to_current_conversation: nil) {|@element| ... } ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/slack/block_kit/layout/input.rb', line 48 def multi_conversations_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil, default_to_current_conversation: nil) @element = Element::MultiConversationsSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji, max_selected_items: max_selected_items, default_to_current_conversation: default_to_current_conversation ) yield(@element) if block_given? self end |
#multi_external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil, max_selected_items: nil) {|@element| ... } ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/slack/block_kit/layout/input.rb', line 175 def multi_external_select( placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil, max_selected_items: nil ) @element = Element::MultiExternalSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, min_query_length: min_query_length, emoji: emoji, max_selected_items: max_selected_items ) yield(@element) if block_given? self end |
#multi_static_select(placeholder:, action_id:, emoji: nil, max_selected_items: nil) {|@element| ... } ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/slack/block_kit/layout/input.rb', line 148 def multi_static_select(placeholder:, action_id:, emoji: nil, max_selected_items: nil) @element = Element::MultiStaticSelect.new( placeholder: placeholder, action_id: action_id, emoji: emoji, max_selected_items: max_selected_items ) yield(@element) if block_given? self end |
#multi_users_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil) {|@element| ... } ⇒ Object
268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/slack/block_kit/layout/input.rb', line 268 def multi_users_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil) @element = Element::MultiUsersSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji, max_selected_items: max_selected_items ) yield(@element) if block_given? self end |
#plain_text_input(action_id:, placeholder: nil, emoji: nil, initial_value: nil, multiline: nil, min_length: nil, max_length: nil) ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/slack/block_kit/layout/input.rb', line 197 def plain_text_input( action_id:, placeholder: nil, emoji: nil, initial_value: nil, multiline: nil, min_length: nil, max_length: nil ) @element = Element::PlainTextInput.new( action_id: action_id, placeholder: placeholder, emoji: emoji, initial_value: initial_value, multiline: multiline, min_length: min_length, max_length: max_length ) self end |
#radio_buttons(action_id:) {|@element| ... } ⇒ Object
247 248 249 250 251 252 253 |
# File 'lib/slack/block_kit/layout/input.rb', line 247 def (action_id:) @element = Element::RadioButtons.new(action_id: action_id) yield(@element) if block_given? self end |
#static_select(placeholder:, action_id:, emoji: nil) {|@element| ... } ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/slack/block_kit/layout/input.rb', line 136 def static_select(placeholder:, action_id:, emoji: nil) @element = Element::StaticSelect.new( placeholder: placeholder, action_id: action_id, emoji: emoji ) yield(@element) if block_given? self end |
#timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) {|@element| ... } ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/slack/block_kit/layout/input.rb', line 98 def timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil) @element = Element::Timepicker.new( action_id: action_id, placeholder: placeholder, emoji: emoji, initial: initial ) yield(@element) if block_given? self end |
#url_text_input(action_id:, placeholder: nil, initial_value: nil, focus_on_load: nil) ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/slack/block_kit/layout/input.rb', line 219 def url_text_input( action_id:, placeholder: nil, initial_value: nil, focus_on_load: nil ) @element = Element::UrlTextInput.new( action_id: action_id, placeholder: placeholder, initial_value: initial_value, focus_on_load: focus_on_load ) end |
#users_select(placeholder:, action_id:, initial: nil, emoji: nil) {|@element| ... } ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/slack/block_kit/layout/input.rb', line 255 def users_select(placeholder:, action_id:, initial: nil, emoji: nil) @element = Element::UsersSelect.new( placeholder: placeholder, action_id: action_id, initial: initial, emoji: emoji ) yield(@element) if block_given? self end |