| 1 |
/** Allows more customization of the pagination dropdown toggle. The following properties |
| 2 |
* should be passed into the pagination component's toggleTemplate property. |
| 3 |
*/ |
| 4 |
|
| 5 |
import { Fragment } from 'react'; |
| 6 |
|
| 7 |
export interface PaginationToggleTemplateProps { |
| 8 |
/** The first index of the items being paginated */ |
| 9 |
firstIndex?: number; |
| 10 |
/** The last index of the items being paginated */ |
| 11 |
lastIndex?: number; |
| 12 |
/** The total number of items being paginated */ |
| 13 |
itemCount?: number; |
| 14 |
/** The type or title of the items being paginated */ |
| 15 |
itemsTitle?: string; |
| 16 |
/** The word that joins the index and itemCount/itemsTitle */ |
| 17 |
ofWord?: React.ReactNode; |
| 18 |
} |
| 19 |
|
| 20 |
export const ToggleTemplate: React.FunctionComponent<PaginationToggleTemplateProps> = ({ |
| 21 |
firstIndex = 0, |
| 22 |
lastIndex = 0, |
| 23 |
itemCount = 0, |
| 24 |
itemsTitle = 'items', |
| 25 |
ofWord = 'of' |
| 26 |
}: PaginationToggleTemplateProps) => ( |
| 27 |
<Fragment> |
| 28 |
<b> |
| 29 |
{firstIndex} - {lastIndex} |
| 30 |
</b>{' '} |
| 31 |
{ofWord} <b>{itemCount}</b> {itemsTitle} |
| 32 |
</Fragment> |
| 33 |
); |
| 34 |
ToggleTemplate.displayName = 'ToggleTemplate'; |