diff --git a/src/shared/components/pagination/pagination.tsx b/src/shared/components/pagination/pagination.tsx index e5d40898c..2bfaf1053 100644 --- a/src/shared/components/pagination/pagination.tsx +++ b/src/shared/components/pagination/pagination.tsx @@ -3,11 +3,15 @@ import { PaginationProps as MantinePaginationProps, } from '@mantine/core'; import clsx from 'clsx'; -import { useRef } from 'react'; +import { useRef, useState } from 'react'; import styles from './pagination.module.css'; +import { ActionIcon } from '/@/shared/components/action-icon/action-icon'; +import { Group } from '/@/shared/components/group/group'; import { Icon } from '/@/shared/components/icon/icon'; +import { NumberInput } from '/@/shared/components/number-input/number-input'; +import { Popover } from '/@/shared/components/popover/popover'; import { Separator } from '/@/shared/components/separator/separator'; import { Text } from '/@/shared/components/text/text'; import { useContainerQuery } from '/@/shared/hooks/use-container-query'; @@ -41,28 +45,74 @@ export const Pagination = ({ const currentPageStartIndex = itemsPerPage * currentPageIndex + 1; const currentPageEndIndex = Math.min(currentPageValue * itemsPerPage, totalItemCount); + const [goToPage, setGoToPage] = useState(currentPageValue); + + const handleGoToPage = () => { + handleChange(Math.max(1, Math.min(goToPage, props.total))); + }; + + const handleGoToKeyDown = (e: React.KeyboardEvent) => { + if (e.key === 'Enter') { + handleGoToPage(); + } + }; + return (
- } - previousIcon={() => } - radius="md" - ref={paginationRef} - siblings={containerQuery.isXl ? 3 : containerQuery.isMd ? 2 : 1} - size="md" - style={{ - ...style, - }} - {...props} - onChange={handleChange} - value={currentPageValue} - /> + + } + previousIcon={() => } + radius="md" + ref={paginationRef} + siblings={containerQuery.isXl ? 3 : containerQuery.isMd ? 2 : 1} + size="md" + style={{ + ...style, + }} + {...props} + onChange={handleChange} + value={currentPageValue} + /> + + + + + + + setGoToPage(Number(e))} + onKeyDown={handleGoToKeyDown} + value={currentPageValue} + width={120} + /> + + + + + {containerQuery.isSm && totalItemCount && ( {currentPageStartIndex} - {currentPageEndIndex} {totalItemCount}