Skip to content

Commit 90ed66e

Browse files
authored
feat(types): add table block (#2426)
1 parent 36c7f2a commit 90ed66e

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

packages/types/src/block-kit/blocks.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ import type {
2424
URLInput,
2525
WorkflowButton,
2626
} from './block-elements';
27-
import type { PlainTextElement, SlackFileImageObject, TextObject, UrlImageObject } from './composition-objects';
27+
import type {
28+
PlainTextElement,
29+
RawTextElement,
30+
SlackFileImageObject,
31+
TextObject,
32+
UrlImageObject,
33+
} from './composition-objects';
2834

2935
export interface Block {
3036
/**
@@ -57,6 +63,7 @@ export type KnownBlock =
5763
| MarkdownBlock
5864
| RichTextBlock
5965
| SectionBlock
66+
| TableBlock
6067
| VideoBlock;
6168

6269
/**
@@ -361,6 +368,40 @@ export interface SectionBlock extends Block {
361368
expand?: boolean;
362369
}
363370

371+
/**
372+
* @description Displays structured information in a table.
373+
* @see {@link https://docs.slack.dev/reference/block-kit/blocks/table-block Table block reference}.
374+
*/
375+
export interface TableBlock extends Block {
376+
/**
377+
* @description The type of block. For a table block, `type` is always `table`.
378+
*/
379+
type: 'table';
380+
/**
381+
* @description An array consisting of table rows. Maximum 100 rows. Each row object is an array with a max of 20 table cells. Table cells can have a type of raw_text or rich_text.
382+
*/
383+
rows: (RichTextBlock | RawTextElement)[][];
384+
/**
385+
* @description An array describing column behavior. If there are fewer items in the column_settings array than there are columns in the table, then the items in the the column_settings array will describe the same number of columns in the table as there are in the array itself. Any additional columns will have the default behavior. Maximum 20 items.
386+
*/
387+
column_settings?: TableBlockColumnSettings[];
388+
}
389+
390+
/**
391+
* Schema for column_settings of the table block.
392+
* @see {@link https://docs.slack.dev/reference/block-kit/blocks/table-block/#schema-for-column_settings}.
393+
*/
394+
interface TableBlockColumnSettings {
395+
/**
396+
* @description The alignment for items in this column. Can be left, center, or right. Defaults to left if not defined.
397+
*/
398+
align?: 'left' | 'center' | 'right';
399+
/**
400+
* @description Whether the contents of this column should be wrapped or not. Defaults to false if not defined.
401+
*/
402+
is_wrapped?: boolean;
403+
}
404+
364405
/**
365406
* @description Displays an embedded video player. A video block is designed to embed videos in all app surfaces (e.g.
366407
* link unfurls, messages, modals, App Home) — anywhere you can put blocks! To use the video block within your app, you

packages/types/src/block-kit/composition-objects.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,21 @@ export interface MrkdwnElement {
173173
verbatim?: boolean;
174174
}
175175

176+
/**
177+
* @description Defines an object containing some text.
178+
* @see {@link https://docs.slack.dev/reference/block-kit/composition-objects/text-object Text object reference}.
179+
*/
180+
export interface RawTextElement {
181+
/**
182+
* @description The formatting to use for this text object.
183+
*/
184+
type: 'raw_text';
185+
/**
186+
* @description The text for the block. The minimum length is 1 and maximum length is 3000 characters.
187+
*/
188+
text: string;
189+
}
190+
176191
interface BaseConversationFilter {
177192
/**
178193
* @description Indicates which type of conversations should be included in the list. When this field is provided, any

0 commit comments

Comments
 (0)