import React from 'react'; import Pagination from '@digigov/react-core/Pagination'; import PaginationLabelContainer, { PaginationLabelContainerProps, } from '@digigov/react-core/PaginationLabelContainer'; import PaginationListItem from '@digigov/react-core/PaginationListItem'; import ChevronIcon from '@digigov/react-icons/ChevronIcon'; import Button from '@digigov/ui/form/Button'; import LabelContainer, { LabelContainerProps, } from '@digigov/ui/form/LabelContainer'; import SelectContainer, { SelectOption, } from '@digigov/ui/form/SelectContainer'; import { I18nText } from '@digigov/ui/i18n/I18nText'; export default Pagination; export interface PaginationLabelProps extends PaginationLabelContainerProps { /** * Use start to set the value of the start point of the results shown. */ start: number; /** * Use end to set the value of the end point of the results shown. */ end: number; /** * Use total to set the value of the total results. */ total: number; } export interface PaginationResultsPerPageSelectProps extends LabelContainerProps { resultsPerPageOptions: number[]; currentResultsPerPage: number; handleOnChange: React.Dispatch>; } export interface PaginationListItemButtonProps { arrow?: 'left' | 'right'; children?: string | number; variant?: 'number' | 'dots'; active?: boolean; onClick?: (e: any) => void; isCurrentPage?: boolean; tabIndex?: number; } /** * PaginationLabel component is used for placing the pagination results label. */ export const PaginationLabel = React.forwardRef< HTMLParagraphElement, PaginationLabelProps >(function PaginationLabel( { start, end, total }, ref: React.Ref ) { return ( Showing {start} to {end} of {total} results ); }); export const PaginationResultsPerPageSelect = React.forwardRef< HTMLLabelElement, PaginationResultsPerPageSelectProps >(function PaginationResultsPerPageSelect( { resultsPerPageOptions, currentResultsPerPage, handleOnChange, children }, ref: React.Ref ) { return ( {children} { handleOnChange(Number(e.target.value)); }} > {resultsPerPageOptions.map((option, index) => ( {option} ))} ); }); export const PaginationListItemButton = React.forwardRef< HTMLLIElement, PaginationListItemButtonProps >(function PaginationListItemButton( { onClick, arrow, children, variant, active, isCurrentPage, tabIndex }, ref: React.Ref ) { return ( <> {isCurrentPage ? ( children ) : ( )} ); });