feat(types): add data_table Block Kit block - #2638
Conversation
🦋 Changeset detectedLatest commit: 3c3194e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2638 +/- ##
=======================================
Coverage 89.12% 89.12%
=======================================
Files 65 65
Lines 10441 10441
Branches 482 481 -1
=======================================
Hits 9306 9306
Misses 1103 1103
Partials 32 32
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Add the `data_table` block (`DataTableBlock`) and the `raw_number` cell composition object (`RawNumberElement`) used for numeric, sortable cells. The block is added to the `KnownBlock` union and covered by tsd type tests. Ref: https://docs.slack.dev/reference/block-kit/blocks/data-table-block Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
The DataTableBlock.rows docstring stated a maximum of 101 rows (100 data rows), but the Block Kit reference documents a maximum of 201 rows (a header row plus 200 data rows). The 100 cap was the page_size maximum, not the row maximum. Align the docstring with docs.slack.dev. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
413eda0 to
e2e26ff
Compare
The DataTableCell alias had a single use site and was not referenced anywhere else, so inline the union directly on `rows` and drop the exported helper type. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Align the DataTableBlock summary and every field @description with the data-table-block reference page, and scope the changeset to the block itself (link + name), each comment on a single line. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Use the reference page's exact wording ("Number of rows per page. Min
`1`, Max `100`. Defaults to `5` if omitted.").
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…tically Place the new raw cell element pair in alphabetical order (Number before Text) as the intended ordering for composition objects going forward. Surrounding definitions are left untouched. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
The rows field's @description had grown into the full docs Fields-table paragraph (row/column min-max, character cap). Those are runtime API limits, not part of the TS type contract, and the cell-type list just restated the union already in the type. Trim to the lead sentence plus the one type-inexpressible constraint: rich_text can't be a header cell. Matches the terse one-sentence @description style of the sibling fields. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
The docs Fields-table Description cell for `rows` is exactly "An array consisting of table rows." The header-row / rich_text constraint lives in the page's usage prose, not the field's Description cell, so it stays out of the @description. Keep the SDK comment to what the docs field description says, nothing added. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Drop the invented tails on RawNumberElement's @descriptions (display text / DataTableBlock sorting framing on the object, "used for sorting the column" on value) that the docs don't carry — the docs describe raw_number minimally (numeric value; type enum; a number; text min length 1). Mirror the terse RawTextElement sibling: an object line, a "formatting to use for this numeric object" type line, and a bare value line. text keeps its display-text + min-length note. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
zimeg
left a comment
There was a problem hiding this comment.
⭐ A comment on changes near for wonderful reviewers!
| /** | ||
| * @description Defines an object containing a numeric value and its display text. Used for numeric cells in a | ||
| * {@link DataTableBlock}, allowing the column to be sorted numerically. | ||
| */ | ||
| export interface RawNumberElement { | ||
| /** | ||
| * @description The formatting to use for this object. | ||
| */ | ||
| type: 'raw_number'; | ||
| /** | ||
| * @description The numeric value used for sorting the column. | ||
| */ | ||
| value: number; | ||
| /** | ||
| * @description The text used to display the value. The minimum length is 1 character. | ||
| */ | ||
| text: string; | ||
| } |
There was a problem hiding this comment.
📣 note: This addresses part of #2689 but not for the table block itself!
Mirror the reviewed node SDK PR (slackapi/node-slack-sdk#2638): - Correct the max row count: the model previously stated up to 100 data rows (101 including header); the reference documents 201 rows (200 data rows plus header). The 100 cap was page_size, not the row maximum. Drop the stale count from the javadoc rather than restate it. - Align each field's javadoc with the data-table-block reference Fields table verbatim (rows, caption, page_size, row_header_column_index). - Trim RawTextDataTableCell / RawNumberDataTableCell to the terse, docs-minimal descriptions (drop the invented sorting/formatting tails); document value and text per the docs. Ref: https://docs.slack.dev/reference/block-kit/blocks/data-table-block Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Use the node @slack/types data_table example (slackapi/node-slack-sdk#2638) — caption "A list of fruit and their quantities", a Fruit/Quantity header with an Apples/raw_number(12) data row — so the SDKs demonstrate the same payload. This also exercises the raw_number cell (and BlockCompositions. rawNumber), which the prior docs-derived example did not. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
srtaalej
left a comment
There was a problem hiding this comment.
thank you for bringing this block to node! LGTM 🌟
| export interface RawNumberElement { | ||
| /** | ||
| * @description The formatting to use for this numeric object. | ||
| */ | ||
| type: 'raw_number'; | ||
| /** | ||
| * @description The numeric value. | ||
| */ | ||
| value: number; | ||
| /** | ||
| * @description The text used to display the value. The minimum length is 1 character. | ||
| */ | ||
| text: string; | ||
| } |
|
@srtaalej And immense thanks for reviews and motivation throughout these blocks building! Let's merge this now to include in an upcoming release. |
Summary
Adds the net-new
data_tableBlock Kit block to@slack/types:DataTableBlockinterface (type: 'data_table') withrows(required),caption(required), and optionalpage_size,row_header_column_index, andblock_id.rowscells accept an inlineraw_text | raw_number | rich_textunion (RawTextElement | RawNumberElement | RichTextBlock), matching the docs data-table-block cell types.RawNumberElementcomposition object (type: 'raw_number',value,text) for numeric, sortable cells.DataTableBlockadded to theKnownBlockunion.Follows the conventions of the existing
TableBlock/AlertBlock/CardBlocktypes and theirRawTextElementcell object.Docs
https://docs.slack.dev/reference/block-kit/blocks/data-table-block
Validation
Run against the
@slack/typesworkspace in an isolated worktree offorigin/main:npm test --workspace=packages/types(runsbuildviatsc+tsdtype tests) — pass. Added happy/sad-pathexpectAssignable/expectErrorcases forDataTableBlockinpackages/types/test/blocks.test-d.ts.npx @biomejs/biome checkon the touched files — pass (also enforced by the repo pre-commit hook across all 637 files — pass).A changeset (
.changeset/data-table-block.md,@slack/typesminor) is included.Co-Authored-By: Claude svc-devxp-claude@slack-corp.com