import { FC } from 'react' import { usePagination } from './usePagination' import { KeyboardArrowLeft, KeyboardArrowRight } from '@/assets' import { clsx } from 'clsx' import s from './pagination.module.scss' type PaginationConditionals = | { onPerPageChange: (itemPerPage: number) => void perPage: number perPageOptions: number[] } | { onPerPageChange?: never perPage?: null perPageOptions?: never } export type PaginationProps = { count: number onChange: (page: number) => void onPerPageChange?: (itemPerPage: number) => void page: number perPage?: number perPageOptions?: number[] siblings?: number } & PaginationConditionals const classNames = { container: s.container, dots: s.dots, icon: s.icon, item: s.item, pageButton(selected?: boolean) { return clsx(this.item, selected && s.selected) }, root: s.root, select: s.select, selectBox: s.selectBox, } export const Pagination: FC = ({ count, onChange, onPerPageChange, page, perPage = null, perPageOptions, siblings, }) => { const { handleMainPageClicked, handleNextPageClicked, handlePreviousPageClicked, isFirstPage, isLastPage, paginationRange, } = usePagination({ count, onChange, page, siblings, }) const showPerPageSelect = !!perPage && !!perPageOptions && !!onPerPageChange return (
{showPerPageSelect && ( )}
) } type NavigationButtonProps = { disabled?: boolean onClick: () => void } type PageButtonProps = NavigationButtonProps & { page: number selected: boolean } const Dots: FC = () => { return } const PageButton: FC = ({ disabled, onClick, page, selected }) => { return ( ) } const PrevButton: FC = ({ disabled, onClick }) => { return ( ) } const NextButton: FC = ({ disabled, onClick }) => { return ( ) } type MainPaginationButtonsProps = { currentPage: number onClick: (pageNumber: number) => () => void paginationRange: (number | string)[] } const MainPaginationButtons: FC = ({ currentPage, onClick, paginationRange, }) => { return ( <> {paginationRange.map((page: number | string, index) => { const isSelected = page === currentPage if (typeof page !== 'number') { return } return ( ) })} ) } export type PerPageSelectProps = { onPerPageChange: (itemPerPage: number) => void perPage: number perPageOptions: number[] } export const PerPageSelect: FC = ( { // perPage, // perPageOptions, // onPerPageChange, } ) => { // const selectOptions = perPageOptions.map(value => ({ // label: value, // value, // })) return (
Показать {/**/} на странице
) }