UNPKG

fox-block-builder

Version:

Maintainable code for loop slack-block-kit-like modal builder

266 lines 12.4 kB
"use strict"; /* eslint-disable max-classes-per-file */ /* eslint-disable max-len */ Object.defineProperty(exports, "__esModule", { value: true }); exports.SubmitDisabled = exports.ResponseUrlEnabled = exports.ReplaceOriginal = exports.Primary = exports.Optional = exports.NotifyOnClose = exports.Multiline = exports.InChannel = exports.IgnoreMarkdown = exports.FocusOnLoad = exports.ExcludeBotUsers = exports.ExcludeExternalSharedChannels = exports.Ephemeral = exports.DispatchActionOnEnterPressed = exports.DispatchActionOnCharacterEntered = exports.DispatchAction = exports.DeleteOriginal = exports.DefaultToCurrentConversation = exports.Danger = exports.ClearOnClose = exports.AsUser = void 0; const lib_1 = require("../lib"); const constants_1 = require("../constants"); class AsUser extends lib_1.Builder { /** * @description Sets the message to be sent as either the user whose auth token is being used or as the bot user associated with your app. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ asUser(boolean = true) { return this.set(boolean, constants_1.Prop.AsUser); } } exports.AsUser = AsUser; class ClearOnClose extends lib_1.Builder { /** * @description Instructs the Slack API to close all open views in the view stack when this particular view is closed. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ clearOnClose(boolean = true) { return this.set(boolean, constants_1.Prop.ClearOnClose); } } exports.ClearOnClose = ClearOnClose; class Danger extends lib_1.Builder { /** * @description For a button element, this changes the color to red. For confirmation dialogs, this sets the main button in the bottom right corner to red, indicating that an action is potentially destructive. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ danger(boolean = true) { return boolean ? this.set(constants_1.ButtonStyle.Danger, constants_1.Prop.Style) : this; } } exports.Danger = Danger; class DefaultToCurrentConversation extends lib_1.Builder { /** * @description Pre-populates the select menu with the conversation that the user was viewing when they opened the modal, if available. * * **Slack Validation Rules and Tips:** * * If initial conversations are provided, this option is ignored. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ defaultToCurrentConversation(boolean = true) { return this.set(boolean, constants_1.Prop.DefaultToCurrentConversation); } } exports.DefaultToCurrentConversation = DefaultToCurrentConversation; class DeleteOriginal extends lib_1.Builder { /** * @description Instructs the Slack API to delete the message from which the interaction originated when sending the current message. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ deleteOriginal(boolean = true) { return this.set(boolean, constants_1.Prop.DeleteOriginal); } } exports.DeleteOriginal = DeleteOriginal; class DispatchAction extends lib_1.Builder { /** * @description Instructs the Slack API to send an interaction event to your app when the element in the input block has been interacted with. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ dispatchAction(boolean = true) { return this.set(boolean, constants_1.Prop.DispatchAction); } } exports.DispatchAction = DispatchAction; class DispatchActionOnCharacterEntered extends lib_1.Builder { /** * @description Instructs the Slack API to dispatch an interaction payload to your app when the user enters or deletes a character in the input. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ dispatchActionOnCharacterEntered(boolean = true) { return boolean ? this.set(constants_1.DispatchOnType.OnCharacterEntered, constants_1.Prop.OnCharacterEntered) : this; } } exports.DispatchActionOnCharacterEntered = DispatchActionOnCharacterEntered; class DispatchActionOnEnterPressed extends lib_1.Builder { /** * @description Instructs the Slack API to dispatch an interaction payload to your app when the user presses the enter key while the input is in focus. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ dispatchActionOnEnterPressed(boolean = true) { return boolean ? this.set(constants_1.DispatchOnType.OnEnterPressed, constants_1.Prop.OnEnterPressed) : this; } } exports.DispatchActionOnEnterPressed = DispatchActionOnEnterPressed; class Ephemeral extends lib_1.Builder { /** * @description Instructs the Slack API to display the message only to the user who invoked the interaction payload or slash command. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ ephemeral(boolean = true) { return boolean ? this.set(constants_1.ResponseType.Ephemeral, constants_1.Prop.ResponseType) : this; } } exports.Ephemeral = Ephemeral; class ExcludeExternalSharedChannels extends lib_1.Builder { /** * @description Excludes conversations shared with external organizations from the menu's options. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ excludeExternalSharedChannels(boolean = true) { return this.set(boolean, constants_1.Prop.ExcludeExternalSharedChannels); } } exports.ExcludeExternalSharedChannels = ExcludeExternalSharedChannels; class ExcludeBotUsers extends lib_1.Builder { /** * @description Excludes conversations with bot users from the menu's options. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ excludeBotUsers(boolean = true) { return this.set(boolean, constants_1.Prop.ExcludeBotUsers); } } exports.ExcludeBotUsers = ExcludeBotUsers; class FocusOnLoad extends lib_1.Builder { /** * @description Sets an element to have auto focus on opening the view * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ focusOnLoad(boolean = true) { return this.set(boolean, constants_1.Prop.FocusOnLoad); } } exports.FocusOnLoad = FocusOnLoad; class IgnoreMarkdown extends lib_1.Builder { /** * @description Instructs the Slack API to ignore any markdown in the text property of the message. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ ignoreMarkdown(boolean = false) { return this.set(boolean, constants_1.Prop.Mrkdwn); } } exports.IgnoreMarkdown = IgnoreMarkdown; class InChannel extends lib_1.Builder { /** * @description Instructs the Slack API to make the message visible to everyone in the channel from which the interaction payload or slash command originated. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ inChannel(boolean = true) { return boolean ? this.set(constants_1.ResponseType.InChannel, constants_1.Prop.ResponseType) : this; } } exports.InChannel = InChannel; class Multiline extends lib_1.Builder { /** * @description Sets the text input to be a larger, multi-line input for larger portions of text. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ multiline(boolean = true) { return this.set(boolean, constants_1.Prop.Multiline); } } exports.Multiline = Multiline; class NotifyOnClose extends lib_1.Builder { /** * @description Instructs the Slack API to send an interaction payload to your app when the view is closed. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ notifyOnClose(boolean = true) { return this.set(boolean, constants_1.Prop.NotifyOnClose); } } exports.NotifyOnClose = NotifyOnClose; class Optional extends lib_1.Builder { /** * @description Lets the Slack API know that inputting data in the the input is not required for the view to be successfully submitted. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ optional(boolean = true) { return this.set(boolean, constants_1.Prop.Optional); } } exports.Optional = Optional; class Primary extends lib_1.Builder { /** * @description For a button element, this changes the color to green. For confirmation dialogs, this sets the main button in the bottom right corner to green, which is meant to confirm the action. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ primary(boolean = true) { return boolean ? this.set(constants_1.ButtonStyle.Primary, constants_1.Prop.Style) : this; } } exports.Primary = Primary; class ReplaceOriginal extends lib_1.Builder { /** * @description Instructs the Slack API to replace the original message, from which the interaction payload originated, with the current message. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ replaceOriginal(boolean = true) { return this.set(boolean, constants_1.Prop.ReplaceOriginal); } } exports.ReplaceOriginal = ReplaceOriginal; class ResponseUrlEnabled extends lib_1.Builder { /** * @description Instructs the Slack API to provide a response URL at view submission. * * **Slack Validation Rules and Tips:** * * Only available in views with input blocks. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ responseUrlEnabled(boolean = true) { return this.set(boolean, constants_1.Prop.ResponseUrlEnabled); } } exports.ResponseUrlEnabled = ResponseUrlEnabled; class SubmitDisabled extends lib_1.Builder { /** * @description Configures the workflow step to have a disabled submit button until the user has input data into one or more inputs. * * {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation} * {@link https://www.blockbuilder.dev|Open Block Builder Documentation} */ submitDisabled(boolean = true) { return this.set(boolean, constants_1.Prop.SubmitDisabled); } } exports.SubmitDisabled = SubmitDisabled; //# sourceMappingURL=configuration-methods.js.map