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.
71 lines (70 loc) • 4.9 kB
TypeScript
import { PaginatorUIComponent, PaginatorPageCountTextFn, PaginatorActionIdFn, PaginatorBuilderFn } from './paginator-ui-component';
import { AccordionUIComponent, AccordionTitleTextFn, AccordionActionIdFn, AccordionBuilderFn } from './accordion-ui-component';
import { PaginatorStateManagerParams, AccordionStateManagerParams } from '../internal';
export type { PaginatorUIComponent, AccordionUIComponent };
interface PaginatorBaseParams<T> {
items: T[];
nextButtonText?: string;
previousButtonText?: string;
pageCountText?: PaginatorPageCountTextFn;
actionId: PaginatorActionIdFn;
blocksForEach: PaginatorBuilderFn<T>;
}
export declare type PaginatorParams<T> = PaginatorBaseParams<T> & PaginatorStateManagerParams;
/**
* @param {Object} [params] Parameters passed to the constructor.
* @param {string} [params.items] An array of items to be displayed in the paginated content.
* @param {int} [params.page] The number of the page to display.
* @param {int} [params.perPage] The number of items to display on a page.
* @param {int} [params.totalItems] The total number of items in the data set across all pages.
* @param {PaginatorActionIdFn} [params.actionId] A function that receives pagination data and returns a string to set as the action IDs of the navigation buttons.
* @param {PaginatorBuilderFn} [params.blocksForEach] A function that receives an object with a single item and returns the blocks to create for that item.
* @param {string} [params.nextButtonText] The text to display on the button that moves forward in the pagination.
* @param {string} [params.previousButtonText] The text to display on the button that moves backward in the pagination.
* @param {PaginatorPageCountTextFn} [params.pageCountText] A function to create a custom page count in the UI.
*
* {@link https://www.blockbuilder.dev/#/components/paginator|View in Block Builder Documentation}
*/
export declare function Paginator<T>(params: PaginatorParams<T>): PaginatorUIComponent<T>;
export declare type EasyPaginatorParams<T> = Omit<PaginatorParams<T>, 'totalItems'>;
/**
* @param {Object} [params] Parameters passed to the constructor.
* @param {string} [params.items] An array of items to be displayed in the paginated content.
* @param {int} [params.page] The number of the page to display.
* @param {int} [params.perPage] The number of items to display on a page.
* @param {PaginatorActionIdFn} [params.actionId] A function that receives pagination data and returns a string to set as the action IDs of the navigation buttons.
* @param {PaginatorBuilderFn} [params.blocksForEach] A function that receives an object with a single item and returns the blocks to create for that item.
* @param {string} [params.nextButtonText] The text to display on the button that moves forward in the pagination.
* @param {string} [params.previousButtonText] The text to display on the button that moves backward in the pagination.
* @param {PaginatorPageCountTextFn} [params.pageCountText] A function to create a custom page count in the UI.
*
* {@link https://www.blockbuilder.dev/#/components/easy-paginator|View in Block Builder Documentation}
*/
export declare function EasyPaginator<T>(params: EasyPaginatorParams<T>): PaginatorUIComponent<T>;
interface AccordionBaseParams<T> {
items: T[];
expandButtonText?: string;
collapseButtonText?: string;
titleText: AccordionTitleTextFn<T>;
actionId: AccordionActionIdFn;
blocksForExpanded: AccordionBuilderFn<T>;
}
export declare type AccordionParams<T> = AccordionBaseParams<T> & AccordionStateManagerParams;
/**
* @param {Object} [params] Parameters passed to the constructor.
* @param {string} [params.items] An array of items to be displayed in the expandable/collapsable content.
* @param {AccordionTitleTextFn} [params.titleText] A function that receives an object with a single item and returns a string to be displayed next to the expand/collapse button.
* @param {AccordionActionIdFn} [params.actionId] A function that receives the accordion state data and returns a string to set as the action IDs of the expand/collapse buttons.
* @param {AccordionBuilderFn} [params.blocksForExpanded] A function that receives an object with a single item and returns the blocks to create for that item.
* @param {string} [params.expandButtonText] The text to display on the button that expands an item in the UI.
* @param {string} [params.collapseButtonText] The text to display on the button that collapses an item in the UI.
*
* {@link https://www.blockbuilder.dev/#/components/accordion|View in Block Builder Documentation}
*/
export declare function Accordion<T>(params: AccordionParams<T>): AccordionUIComponent<T>;
declare const components: {
Paginator: typeof Paginator;
EasyPaginator: typeof EasyPaginator;
Accordion: typeof Accordion;
};
export { components as Components };