import { type ReactElement, type ReactNode, type PropsWithChildren } from 'react'; import type { RowModel, Table, TableFeature, TableOptions, Updater } from '../../hooks/useTable/types.js'; /** * @public */ export interface DataTableV2PaginationBaseProps { /** * The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */ id?: string; /** * Test id used for matching the pagination container. */ 'data-testid'?: string; /** * Page size options to be displayed in the page size select. * @defaultValue [10, 20, 50, 100, 250, 500, 1000] */ pageSizeOptions?: number[]; /** * Allows opting out of automatic page index reset when new data is being set. * Be aware that if you turn off `autoResetPageIndex`, you may need to add logic * to handle resetting the pageIndex yourself. * * @remarks If the page index is resetting when you think it should not be, before * using this setting, check that you have your table input objects properly * memoized (for example rowSelection object). * @defaultValue true */ autoResetPageIndex?: boolean; /** Called when the page index changes. Provides the changed page index along with the underlying trigger. */ onPageIndexChange?: (pageIndex: number, trigger: 'user' | 'internal') => void; /** Handler that is called when the page size changes. */ onPageSizeChange?: (pageSize: number) => void; } /** * @public */ export interface DataTableV2PaginationPageIndexUncontrolledProps extends DataTableV2PaginationBaseProps { /** * Initial page index in an uncontrolled scenario. * @defaultValue 0 */ defaultPageIndex?: number; /** Current page index in a controlled scenario. */ pageIndex?: never; } /** * @public */ export interface DataTableV2PaginationPageIndexControlledProps extends DataTableV2PaginationBaseProps { /** * Initial page index in an uncontrolled scenario. * @defaultValue 0 */ defaultPageIndex?: never; /** Current page index in a controlled scenario. */ pageIndex: number; } /** * @public */ export interface DataTableV2PaginationPageSizeUncontrolledProps extends DataTableV2PaginationBaseProps { /** * Default number of rows per page (uncontrolled). * @defaultValue 100 */ defaultPageSize?: number; /** Number of rows per page (controlled) */ pageSize?: never; } /** * @public */ export interface DataTableV2PaginationPageSizeControlledProps extends DataTableV2PaginationBaseProps { /** * Default number of rows per page (uncontrolled). * @defaultValue 100 */ defaultPageSize?: never; /** Number of rows per page (controlled) */ pageSize: number; } /** * @public */ export interface DataTableV2PaginationClientSideProps extends DataTableV2PaginationBaseProps { /** Whether the previous page is available (if not, the go to previous page button should be disabled). */ enablePreviousPage?: never; /** Whether the next page is available (if not, the go to next page button should be disabled). */ enableNextPage?: never; /** * The total number of rows. * Will be used to determine the total number of pages to display the indicator "Page X of Y" for server-side pagination. */ totalRowsCount?: never; } /** * @public */ export interface DataTableV2PaginationServerSideProps extends DataTableV2PaginationBaseProps { /** Whether the previous page is available (if not, the go to previous page button should be disabled). */ enablePreviousPage: boolean; /** Whether the next page is available (if not, the go to next page button should be disabled). */ enableNextPage: boolean; /** * The total number of rows. * Will be used to determine the total number of pages to display the indicator "Page X of Y" for server-side pagination. */ totalRowsCount?: number; } /** * DataTableV2.Pagination props. * @public */ export type DataTableV2PaginationProps = (DataTableV2PaginationPageIndexUncontrolledProps | DataTableV2PaginationPageIndexControlledProps) & (DataTableV2PaginationPageSizeUncontrolledProps | DataTableV2PaginationPageSizeControlledProps) & (DataTableV2PaginationClientSideProps | DataTableV2PaginationServerSideProps); /** * DataTableV2 slot definition. * @public */ export declare function DataTableV2Pagination(props: DataTableV2PaginationProps): null; /** * Helper function that will check if a passed component is of type `DataTableV2Pagination` * @internal */ export declare function _isDataTableV2Pagination(child: ReactNode): child is ReactElement; /** @internal */ export interface DataTableV2PaginationState { pageIndex: number; pageSize: number; enableNextPage?: boolean; enablePreviousPage?: boolean; totalRowsCount?: number; } /** @internal */ export interface DataTableV2PaginationOptions { enablePagination?: boolean; availablePaginationOptions?: number[]; autoResetPageIndex?: boolean; getPaginationRowModel?: (table: Table) => () => RowModel; manualPagination?: boolean; onPaginationChange?: (updaterOrValue: Updater, trigger?: 'user' | 'internal') => void; pageCount?: number; /** * Whether the page index is controlled. */ controlledPageIndex?: boolean; } /** @internal */ export interface DataTableV2PaginationInitialTableState { pagination?: Partial; } /** @internal */ export interface DataTableV2PaginationTableState { pagination: DataTableV2PaginationState; } /** @internal */ export interface DataTableV2PaginationInstance { /** * Updates the page index using the provided function or value. * @param updater - update function or value * @param trigger - whether the change was triggered by user interaction or internally */ setPageIndex: (updater: Updater, trigger?: 'user' | 'internal') => void; /** * Sets or updates the pagination state. * @param updater - update function or value * @param trigger - whether the change was triggered by user interaction or internally */ setPagination: (updater: Updater, trigger?: 'user' | 'internal') => void; /** * For uncontrolled pagination, if there are no rows to display on the current page, * the page index is set to the last non-empty page. */ updatePageIndexOnEmptyPage: () => void; } /** * @internal */ export declare const DataTableV2PaginationFeature: TableFeature; /** * Configuration hook for pagination of the DataTableV2. * @internal */ export declare function usePagination(props: PropsWithChildren, options: TableOptions): void;