Slackblocks.Components.Paginator (slackblocks v2.8.0)

View Source

Pure pagination into ordinary blocks. Interaction routing and state belong to your application.

Summary

Functions

Selects a page from a nonempty block list and appends navigation when needed.

Like to_blocks/2, raising on invalid input.

Functions

to_blocks(blocks, options)

@spec to_blocks(
  [Slackblocks.Types.block()],
  keyword()
) ::
  {:ok, [Slackblocks.Types.block()]} | {:error, Slackblocks.ValidationError.t()}

Selects a page from a nonempty block list and appends navigation when needed.

Requires action_id_prefix. Options are page (1), page_size (5), previous_text ("Previous"), next_text ("Next"), show_page_indicator (true) and the navigation block_id (nil). Buttons use .previous/.next suffixes and decimal page numbers as values. Page numbers start at one.

Controls are additional blocks. Put the expanded list in a message or view to validate that surface's total block count. No IDs are generated implicitly.

to_blocks!(blocks, options)

@spec to_blocks!(
  [Slackblocks.Types.block()],
  keyword()
) :: [Slackblocks.Types.block()]

Like to_blocks/2, raising on invalid input.