Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slack-block-builder

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slack-block-builder - npm Package Compare versions

Comparing version 2.7.2 to 2.8.0

dist/elements/file-input.d.ts

1

dist/blocks/video.d.ts
import { BlockBuilderBase } from '../internal/base';
import { AltText, AuthorName, BlockId, Description, End, ProviderIconUrl, ProviderName, ThumbnailUrl, Title, TitleUrl, VideoUrl } from '../internal/methods';
export interface VideoParams {
altText?: string;
blockId?: string;

@@ -5,0 +6,0 @@ description?: string;

@@ -13,2 +13,3 @@ import { AccordionStateManager, AccordionState } from '../internal/lib';

}>;
export declare type AccordionIsExpandableFn<T> = (item: T) => boolean;
export interface AccordionUIComponentParams<T> {

@@ -22,2 +23,3 @@ items: T[];

builderFunction: AccordionBuilderFn<T>;
isExpandableFunction: AccordionIsExpandableFn<T>;
}

@@ -32,4 +34,5 @@ export declare class AccordionUIComponent<T> {

private readonly builderFunction;
private readonly isExpandableFunction;
constructor(params: AccordionUIComponentParams<T>);
getBlocks(): BlockBuilder[];
}

12

dist/components/accordion-ui-component.js

@@ -17,2 +17,3 @@ "use strict";

this.builderFunction = params.builderFunction;
this.isExpandableFunction = params.isExpandableFunction;
}

@@ -22,5 +23,5 @@ getBlocks() {

const isExpanded = this.paginator.checkItemIsExpandedByIndex(index);
const blocks = [
blocks_1.Blocks.Section({ text: this.titleTextFunction({ item }) })
.accessory(elements_1.Elements.Button({
const section = blocks_1.Blocks.Section({ text: this.titleTextFunction({ item }) });
if (this.isExpandableFunction(item)) {
section.accessory(elements_1.Elements.Button({
text: isExpanded ? this.collapseButtonText : this.expandButtonText,

@@ -30,3 +31,6 @@ actionId: this.actionIdFunction({

}),
})),
}));
}
const blocks = [
section,
...isExpanded ? this.builderFunction({ item }).flat() : [],

@@ -33,0 +37,0 @@ ];

import { PaginatorUIComponent, PaginatorPageCountTextFn, PaginatorActionIdFn, PaginatorBuilderFn } from './paginator-ui-component';
import { AccordionUIComponent, AccordionTitleTextFn, AccordionActionIdFn, AccordionBuilderFn } from './accordion-ui-component';
import { AccordionUIComponent, AccordionTitleTextFn, AccordionActionIdFn, AccordionBuilderFn, AccordionIsExpandableFn } from './accordion-ui-component';
import { PaginatorStateManagerParams, AccordionStateManagerParams } from '../internal';

@@ -51,2 +51,3 @@ export type { PaginatorUIComponent, AccordionUIComponent };

blocksForExpanded: AccordionBuilderFn<T>;
isExpandable?: AccordionIsExpandableFn<T>;
}

@@ -60,2 +61,3 @@ export declare type AccordionParams<T> = AccordionBaseParams<T> & AccordionStateManagerParams;

* @param {AccordionBuilderFn} [params.blocksForExpanded] A function that receives an object with a single item and returns the blocks to create for that item.
* @param {AccordionIsExpandableFn} [params.isExpandable] A function that receives an item and and returns a boolean that tells if the section should have an expand/collapse button.
* @param {string} [params.expandButtonText] The text to display on the button that expands an item in the UI.

@@ -62,0 +64,0 @@ * @param {string} [params.collapseButtonText] The text to display on the button that collapses an item in the UI.

@@ -71,2 +71,3 @@ "use strict";

* @param {AccordionBuilderFn} [params.blocksForExpanded] A function that receives an object with a single item and returns the blocks to create for that item.
* @param {AccordionIsExpandableFn} [params.isExpandable] A function that receives an item and and returns a boolean that tells if the section should have an expand/collapse button.
* @param {string} [params.expandButtonText] The text to display on the button that expands an item in the UI.

@@ -88,2 +89,3 @@ * @param {string} [params.collapseButtonText] The text to display on the button that collapses an item in the UI.

builderFunction: params.blocksForExpanded,
isExpandableFunction: params.isExpandable || (() => true),
});

@@ -90,0 +92,0 @@ }

@@ -12,2 +12,3 @@ import { ButtonBuilder, ButtonParams } from './button';

import { ExternalSelectBuilder, ExternalSelectParams } from './external-select';
import { FileInputBuilder, FileInputParams } from './file-input';
import { ImgBuilder, ImgParams } from './img';

@@ -24,3 +25,3 @@ import { NumberInputBuilder, NumberInputParams } from './number-input';

import { UserSelectBuilder, UserSelectParams } from './user-select';
export type { ButtonBuilder, ButtonParams, ChannelMultiSelectBuilder, ChannelMultiSelectParams, ChannelSelectBuilder, ChannelSelectParams, CheckboxesBuilder, CheckboxesParams, ConversationMultiSelectBuilder, ConversationMultiSelectParams, ConversationSelectBuilder, ConversationSelectParams, DatePickerBuilder, DatePickerParams, DateTimePickerBuilder, DateTimePickerParams, EmailInputBuilder, EmailInputParams, ExternalMultiSelectBuilder, ExternalMultiSelectParams, ExternalSelectBuilder, ExternalSelectParams, ImgBuilder, ImgParams, NumberInputBuilder, NumberInputParams, OverflowMenuBuilder, OverflowMenuParams, RadioButtonsBuilder, RadioButtonsParams, StaticMultiSelectBuilder, StaticMultiSelectParams, StaticSelectBuilder, StaticSelectParams, TextInputBuilder, TextInputParams, TimePickerBuilder, TimePickerParams, URLInputBuilder, URLInputParams, UserMultiSelectBuilder, UserMultiSelectParams, UserSelectBuilder, UserSelectParams, };
export type { ButtonBuilder, ButtonParams, ChannelMultiSelectBuilder, ChannelMultiSelectParams, ChannelSelectBuilder, ChannelSelectParams, CheckboxesBuilder, CheckboxesParams, ConversationMultiSelectBuilder, ConversationMultiSelectParams, ConversationSelectBuilder, ConversationSelectParams, DatePickerBuilder, DatePickerParams, DateTimePickerBuilder, DateTimePickerParams, EmailInputBuilder, EmailInputParams, ExternalMultiSelectBuilder, ExternalMultiSelectParams, ExternalSelectBuilder, ExternalSelectParams, ImgBuilder, ImgParams, NumberInputBuilder, NumberInputParams, OverflowMenuBuilder, OverflowMenuParams, RadioButtonsBuilder, RadioButtonsParams, StaticMultiSelectBuilder, StaticMultiSelectParams, StaticSelectBuilder, StaticSelectParams, TextInputBuilder, TextInputParams, TimePickerBuilder, TimePickerParams, URLInputBuilder, URLInputParams, UserMultiSelectBuilder, UserMultiSelectParams, UserSelectBuilder, UserSelectParams, FileInputBuilder, FileInputParams, };
/**

@@ -138,2 +139,10 @@ * Functions here do not use arrow functions stored in variables for IDE color compatibility.

* @param {Object} [params] Parameters passed to the constructor.
* @param {string} [params.filetypes] Sets the accepted filetypes.
* @param {string} [params.maxFiles] Sets the maximum number of files to upload.
*
* {@link https://api.slack.com/reference/block-kit/block-elements#file_input|View in Slack API Documentation}
*/
export declare function FileInput(params?: FileInputParams): FileInputBuilder;
/**
* @param {Object} [params] Parameters passed to the constructor.
* @param {string} [params.actionId] Sets a string to be an identifier for the source of an action in interaction payloads.

@@ -185,2 +194,3 @@ * @param {boolean} [params.isDecimalAllowed] Dicates whether a decimal is allowed for the value entered into the number input.

* @param {string} [params.initialValue] Sets the default text entered into the text input at modal render.
* @param {boolean} [params.multiline] Sets whether the input will be a single line or a larger text area.
* @param {int} [params.minLength] Sets a minimum character count in order for the user to submit the form.

@@ -251,3 +261,4 @@ * @param {int} [params.maxLength] Sets a maximum character count allowed to send the form.

UserSelect: typeof UserSelect;
FileInput: typeof FileInput;
};
export { elements as Elements };
"use strict";
/* eslint-disable max-len */
Object.defineProperty(exports, "__esModule", { value: true });
exports.Elements = exports.UserSelect = exports.UserMultiSelect = exports.URLInput = exports.TimePicker = exports.TextInput = exports.StaticSelect = exports.StaticMultiSelect = exports.RadioButtons = exports.OverflowMenu = exports.NumberInput = exports.Img = exports.ExternalSelect = exports.ExternalMultiSelect = exports.EmailInput = exports.DateTimePicker = exports.DatePicker = exports.ConversationSelect = exports.ConversationMultiSelect = exports.Checkboxes = exports.ChannelSelect = exports.ChannelMultiSelect = exports.Button = void 0;
exports.Elements = exports.UserSelect = exports.UserMultiSelect = exports.URLInput = exports.TimePicker = exports.TextInput = exports.StaticSelect = exports.StaticMultiSelect = exports.RadioButtons = exports.OverflowMenu = exports.NumberInput = exports.FileInput = exports.Img = exports.ExternalSelect = exports.ExternalMultiSelect = exports.EmailInput = exports.DateTimePicker = exports.DatePicker = exports.ConversationSelect = exports.ConversationMultiSelect = exports.Checkboxes = exports.ChannelSelect = exports.ChannelMultiSelect = exports.Button = void 0;
const button_1 = require("./button");

@@ -16,2 +16,3 @@ const channel_multi_select_1 = require("./channel-multi-select");

const external_select_1 = require("./external-select");
const file_input_1 = require("./file-input");
const img_1 = require("./img");

@@ -176,2 +177,13 @@ const number_input_1 = require("./number-input");

* @param {Object} [params] Parameters passed to the constructor.
* @param {string} [params.filetypes] Sets the accepted filetypes.
* @param {string} [params.maxFiles] Sets the maximum number of files to upload.
*
* {@link https://api.slack.com/reference/block-kit/block-elements#file_input|View in Slack API Documentation}
*/
function FileInput(params) {
return new file_input_1.FileInputBuilder(params);
}
exports.FileInput = FileInput;
/**
* @param {Object} [params] Parameters passed to the constructor.
* @param {string} [params.actionId] Sets a string to be an identifier for the source of an action in interaction payloads.

@@ -238,2 +250,3 @@ * @param {boolean} [params.isDecimalAllowed] Dicates whether a decimal is allowed for the value entered into the number input.

* @param {string} [params.initialValue] Sets the default text entered into the text input at modal render.
* @param {boolean} [params.multiline] Sets whether the input will be a single line or a larger text area.
* @param {int} [params.minLength] Sets a minimum character count in order for the user to submit the form.

@@ -319,3 +332,4 @@ * @param {int} [params.maxLength] Sets a maximum character count allowed to send the form.

UserSelect,
FileInput,
};
exports.Elements = elements;

@@ -6,2 +6,3 @@ import { ElementBuilderBase } from '../internal/base';

initialValue?: string;
multiline?: boolean;
maxLength?: number;

@@ -8,0 +9,0 @@ minLength?: number;

@@ -23,3 +23,4 @@ export declare enum ElementType {

EmailInput = "email_text_input",
NumberInput = "number_input"
NumberInput = "number_input",
FileInput = "file_input"
}

@@ -28,2 +28,3 @@ "use strict";

ElementType["NumberInput"] = "number_input";
ElementType["FileInput"] = "file_input";
})(ElementType = exports.ElementType || (exports.ElementType = {}));

@@ -89,3 +89,5 @@ export declare enum Prop {

ThumbnailUrl = "thumbnailUrl",
VideoUrl = "videoUrl"
VideoUrl = "videoUrl",
MaxFiles = "maxFiles",
Filetypes = "filetypes"
}

@@ -94,2 +94,4 @@ "use strict";

Prop["VideoUrl"] = "videoUrl";
Prop["MaxFiles"] = "maxFiles";
Prop["Filetypes"] = "filetypes";
})(Prop = exports.Prop || (exports.Prop = {}));

@@ -82,3 +82,6 @@ import { SurfaceType, BlockType, ElementType } from '../constants';

minValue = "min_value",
maxValue = "max_value"
maxValue = "max_value",
maxFiles = "max_files",
filetypes = "filetypes",
source = "source"
}

@@ -92,2 +95,3 @@ export declare class SlackDto implements ObjectLiteral {

readonly channel: string;
readonly ts: string;
readonly blocks?: SlackBlockDto[];

@@ -94,0 +98,0 @@ readonly attachments?: SlackDto[];

@@ -87,2 +87,5 @@ "use strict";

Param["maxValue"] = "max_value";
Param["maxFiles"] = "max_files";
Param["filetypes"] = "filetypes";
Param["source"] = "source";
})(Param = exports.Param || (exports.Param = {}));

@@ -89,0 +92,0 @@ class SlackDto {

@@ -571,1 +571,25 @@ import { Builder } from '../lib';

}
export declare abstract class MaxFiles extends Builder {
/**
* @description Maximum number of files that can be uploaded for this file_input element. Minimum of 1, maximum of 10. Defaults to 10 if not specified.
*
* {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation}
* {@link https://www.blockbuilder.dev|Open Block Builder Documentation}
*/
maxFiles(maxFiles?: Settable<number>): this;
}
export declare abstract class Filetypes extends Builder {
/**
* @description An array of valid file extensions that will be accepted for this element. All file extensions will be accepted if filetypes is not specified.
*
* **Slack Validation Rules and Tips:**
* * **Required if the text property is undefined** ⚠
* * Maximum of 10 items.
* * Maximum of 2000 characters for each field.
* * Markdown supported.
*
* {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation}
* {@link https://www.blockbuilder.dev|Open Block Builder Documentation}
*/
filetypes(filetypes?: Settable<string[]>): this;
}

@@ -5,3 +5,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.VideoUrl = exports.Value = exports.Url = exports.Ts = exports.TitleUrl = exports.Title = exports.ThumbnailUrl = exports.ThreadTs = exports.Text = exports.Submit = exports.ProviderName = exports.ProviderIconUrl = exports.PrivateMetaData = exports.PostAt = exports.Placeholder = exports.MinValue = exports.MinLength = exports.MinQueryLength = exports.MaxValue = exports.MaxSelectedItems = exports.MaxLength = exports.Label = exports.IsDecimalAllowed = exports.InitialValue = exports.InitialUser = exports.InitialTime = exports.InitialOption = exports.InitialDateTime = exports.InitialDate = exports.InitialConversation = exports.InitialChannel = exports.ImageUrl = exports.Hint = exports.Fallback = exports.ExternalId = exports.Element = exports.Description = exports.Deny = exports.Confirm = exports.Color = exports.Close = exports.Channel = exports.CallbackId = exports.BlockId = exports.AuthorName = exports.AltText = exports.ActionId = exports.Accessory = exports.AccessibilityLabel = void 0;
exports.MaxFiles = exports.VideoUrl = exports.Value = exports.Url = exports.Ts = exports.TitleUrl = exports.Title = exports.ThumbnailUrl = exports.ThreadTs = exports.Text = exports.Submit = exports.ProviderName = exports.ProviderIconUrl = exports.PrivateMetaData = exports.PostAt = exports.Placeholder = exports.MinValue = exports.MinLength = exports.MinQueryLength = exports.MaxValue = exports.MaxSelectedItems = exports.MaxLength = exports.Label = exports.IsDecimalAllowed = exports.InitialValue = exports.InitialUser = exports.InitialTime = exports.InitialOption = exports.InitialDateTime = exports.InitialDate = exports.InitialConversation = exports.InitialChannel = exports.ImageUrl = exports.Hint = exports.Fallback = exports.ExternalId = exports.Element = exports.Description = exports.Deny = exports.Confirm = exports.Color = exports.Close = exports.Channel = exports.CallbackId = exports.BlockId = exports.AuthorName = exports.AltText = exports.ActionId = exports.Accessory = exports.AccessibilityLabel = void 0;
exports.Filetypes = void 0;
const lib_1 = require("../lib");

@@ -723,1 +724,31 @@ const constants_1 = require("../constants");

exports.VideoUrl = VideoUrl;
class MaxFiles extends lib_1.Builder {
/**
* @description Maximum number of files that can be uploaded for this file_input element. Minimum of 1, maximum of 10. Defaults to 10 if not specified.
*
* {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation}
* {@link https://www.blockbuilder.dev|Open Block Builder Documentation}
*/
maxFiles(maxFiles = 10) {
return this.set(maxFiles, constants_1.Prop.MaxFiles);
}
}
exports.MaxFiles = MaxFiles;
class Filetypes extends lib_1.Builder {
/**
* @description An array of valid file extensions that will be accepted for this element. All file extensions will be accepted if filetypes is not specified.
*
* **Slack Validation Rules and Tips:**
* * **Required if the text property is undefined** ⚠
* * Maximum of 10 items.
* * Maximum of 2000 characters for each field.
* * Markdown supported.
*
* {@link https://api.slack.com/block-kit|Open Official Slack Block Kit Documentation}
* {@link https://www.blockbuilder.dev|Open Block Builder Documentation}
*/
filetypes(filetypes = []) {
return this.set(filetypes.flat(), constants_1.Prop.Filetypes);
}
}
exports.Filetypes = Filetypes;

@@ -1,2 +0,2 @@

import type { ButtonBuilder, ChannelMultiSelectBuilder, ChannelSelectBuilder, CheckboxesBuilder, ConversationMultiSelectBuilder, ConversationSelectBuilder, DatePickerBuilder, DateTimePickerBuilder, ExternalMultiSelectBuilder, ExternalSelectBuilder, ImgBuilder, OverflowMenuBuilder, RadioButtonsBuilder, StaticMultiSelectBuilder, StaticSelectBuilder, TextInputBuilder, TimePickerBuilder, UserMultiSelectBuilder, UserSelectBuilder } from '../../elements';
import type { ButtonBuilder, ChannelMultiSelectBuilder, ChannelSelectBuilder, CheckboxesBuilder, ConversationMultiSelectBuilder, ConversationSelectBuilder, DatePickerBuilder, DateTimePickerBuilder, ExternalMultiSelectBuilder, ExternalSelectBuilder, FileInputBuilder, ImgBuilder, OverflowMenuBuilder, RadioButtonsBuilder, StaticMultiSelectBuilder, StaticSelectBuilder, TextInputBuilder, TimePickerBuilder, UserMultiSelectBuilder, UserSelectBuilder } from '../../elements';
import type { ActionsBuilder, ContextBuilder, DividerBuilder, FileBuilder, HeaderBuilder, ImageBuilder, InputBuilder, SectionBuilder, VideoBuilder } from '../../blocks';

@@ -6,3 +6,3 @@ import { EmailInputBuilder, NumberInputBuilder, URLInputBuilder } from '../../elements';

export declare type SectionElementBuilder = ButtonBuilder | ChannelMultiSelectBuilder | ChannelSelectBuilder | CheckboxesBuilder | ConversationMultiSelectBuilder | ConversationSelectBuilder | DatePickerBuilder | ExternalMultiSelectBuilder | ExternalSelectBuilder | ImgBuilder | OverflowMenuBuilder | RadioButtonsBuilder | StaticMultiSelectBuilder | StaticSelectBuilder | TimePickerBuilder | UserMultiSelectBuilder | UserSelectBuilder;
export declare type InputElementBuilder = ChannelMultiSelectBuilder | ChannelSelectBuilder | CheckboxesBuilder | ConversationMultiSelectBuilder | ConversationSelectBuilder | DatePickerBuilder | DateTimePickerBuilder | EmailInputBuilder | ExternalMultiSelectBuilder | ExternalSelectBuilder | NumberInputBuilder | RadioButtonsBuilder | StaticMultiSelectBuilder | StaticSelectBuilder | TextInputBuilder | TimePickerBuilder | URLInputBuilder | UserMultiSelectBuilder | UserSelectBuilder;
export declare type InputElementBuilder = ChannelMultiSelectBuilder | ChannelSelectBuilder | CheckboxesBuilder | ConversationMultiSelectBuilder | ConversationSelectBuilder | DatePickerBuilder | DateTimePickerBuilder | EmailInputBuilder | ExternalMultiSelectBuilder | ExternalSelectBuilder | NumberInputBuilder | RadioButtonsBuilder | StaticMultiSelectBuilder | StaticSelectBuilder | TextInputBuilder | TimePickerBuilder | URLInputBuilder | UserMultiSelectBuilder | UserSelectBuilder | FileInputBuilder;
export declare type ContextElement = ImgBuilder | string;

@@ -9,0 +9,0 @@ export declare type BlockBuilder = ActionsBuilder | ContextBuilder | DividerBuilder | FileBuilder | HeaderBuilder | ImageBuilder | InputBuilder | SectionBuilder | ViewBlockBuilder;

{
"name": "slack-block-builder",
"version": "2.7.2",
"version": "2.8.0",
"description": "Maintainable code for interactive Slack messages, modals, home tabs, and workflow steps. A must-have for the Slack Block Kit framework.",

@@ -5,0 +5,0 @@ "author": {

@@ -151,2 +151,3 @@ :information_source: **Block Builder** was built in Kyiv, Ukraine :ukraine: If it has saved you time as a developer and brought value to your projects and products, we would like to ask you to consider donating to **[Come Back Alive](https://savelife.in.ua/en/donate/)** to help Ukraine in its fight against Russian aggression. Every cent helps. :pray:

| Email Input | Element | :white_check_mark: | `Elements.EmailInput()`
| File Input | Element | :white_check_mark: | `Elements.FileInput()`
| Time Picker | Element | :white_check_mark: | `Elements.TimePicker()`

@@ -322,2 +323,4 @@ | Image | Element | :white_check_mark: | `Elements.Img()`

`collapseButtonText` – Used to pass in custom text for the button that collapses an expanded item, but has a default.
`isExpandable` – Used to display or not the expand/collapse button for a given item.

@@ -324,0 +327,0 @@ ```javascript

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc