All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.slack.api.model.kotlin_extension.block.element.EmailTextInputElementBuilder.kt Maven / Gradle / Ivy

The newest version!
package com.slack.api.model.kotlin_extension.block.element

import com.slack.api.model.block.composition.DispatchActionConfig
import com.slack.api.model.block.composition.PlainTextObject
import com.slack.api.model.block.element.EmailTextInputElement
import com.slack.api.model.kotlin_extension.block.BlockLayoutBuilder
import com.slack.api.model.kotlin_extension.block.Builder
import com.slack.api.model.kotlin_extension.block.composition.DispatchActionConfigBuilder

@BlockLayoutBuilder
class EmailTextInputElementBuilder : Builder {
    private var actionId: String? = null
    private var placeholder: PlainTextObject? = null
    private var initialValue: String? = null
    private var dispatchActionConfig: DispatchActionConfig? = null
    private var _focusOnLoad: Boolean? = null

    /**
     * An identifier for the input value when the parent modal is submitted. You can use this when you receive a
     * view_submission payload to identify the value of the input element. Should be unique among all other action_ids
     * used elsewhere by your app. Maximum length for this field is 255 characters.*
     *
     * @see Email text input documentation
     */
    fun actionId(id: String) {
        actionId = id
    }

    /**
     * Adds a plain text object to the placeholder field.
     *
     * The placeholder text shown in the plain-text input. Maximum length for the text in this field is 150 characters.
     *
     * @see Email text input documentation
     */
    fun placeholder(text: String, emoji: Boolean? = null) {
        placeholder = PlainTextObject(text, emoji)
    }

    /**
     * The initial value in the plain-text input when it is loaded.
     *
     * @see Email text input documentation
     */
    fun initialValue(value: String) {
        initialValue = value
    }

    /**
     * Determines when a plain-text input element will return a block_actions interaction payload.
     *
     * @see The document
     */
    fun dispatchActionConfig(builder: DispatchActionConfigBuilder.() -> Unit) {
        dispatchActionConfig = DispatchActionConfigBuilder().apply(builder).build()
    }

    /**
     * Indicates whether the element will be set to autofocus within the view object.
     * Only one element can be set to true. Defaults to false.
     *
     * @see The document
     */
    fun focusOnLoad(focusOnLoad: Boolean) {
        _focusOnLoad = focusOnLoad
    }

    override fun build(): EmailTextInputElement {
        return EmailTextInputElement.builder()
            .actionId(actionId)
            .placeholder(placeholder)
            .initialValue(initialValue)
            .dispatchActionConfig(dispatchActionConfig)
            .focusOnLoad(_focusOnLoad)
            .build()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy