UNPKG

fox-slack-block-builder

Version:

Maintainable code for interactive Slack messages, modals, home tabs, and workflow steps. A must-have for the Slack Block Kit framework.

53 lines (52 loc) 2.01 kB
"use strict"; /* eslint-disable max-len */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Utilities = exports.buildBlocks = exports.buildBlock = exports.OptionGroupCollection = exports.OptionCollection = exports.AttachmentCollection = exports.BlockCollection = void 0; const lib_1 = require("../internal/lib"); const getBuiltCollection = (...builders) => lib_1.Builder.pruneUndefinedFromArray(builders.flat()) .map((builder) => builder && builder.build()); /** * @description Creates and returns an array of built blocks. Behaves in the same way as all appending methods, such as Surface.blocks(). */ function BlockCollection(...blocks) { return getBuiltCollection(...blocks); } exports.BlockCollection = BlockCollection; /** * @description Creates and returns an array of built attachments. Behaves in the same way as all appending methods, such as Message.attachments(). */ function AttachmentCollection(...attachments) { return getBuiltCollection(...attachments); } exports.AttachmentCollection = AttachmentCollection; function OptionCollection(...options) { return getBuiltCollection(...options); } exports.OptionCollection = OptionCollection; function OptionGroupCollection(...optionGroups) { return getBuiltCollection(...optionGroups); } exports.OptionGroupCollection = OptionGroupCollection; /** * @description Returns the block passed into the function as a built block, an object that conforms to the Slack API. */ function buildBlock(block) { return block.build(); } exports.buildBlock = buildBlock; /** * @description Creates and returns an array of built blocks. Behaves in the same way as all appending methods, such as Surface.blocks(). */ function buildBlocks(...blocks) { return getBuiltCollection(...blocks); } exports.buildBlocks = buildBlocks; const utilities = { AttachmentCollection, BlockCollection, OptionCollection, OptionGroupCollection, buildBlock, buildBlocks, }; exports.Utilities = utilities;