Debian Codegraph @

node/@patternfly/react-core/src/components/Pagination/examples/PaginationOffset.tsx

raw
1 import { useState } from 'react';
2 import { Pagination } from '@patternfly/react-core';
3
4 export const PaginationOffset: React.FunctionComponent = () => {
5 const [offset, setOffset] = useState(7);
6 const [perPage, setPerPage] = useState(20);
7
8 const onSetPage = (
9 _event: React.MouseEvent | React.KeyboardEvent | MouseEvent,
10 newPage: number,
11 _perPage: number | undefined,
12 startIdx: number | undefined
13 ) => {
14 setOffset(startIdx || 0);
15 };
16 const onPerPageSelect = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPerPage: number) => {
17 setPerPage(newPerPage);
18 setOffset(0);
19 };
20
21 return (
22 <Pagination
23 itemCount={523}
24 perPage={perPage}
25 offset={offset}
26 onSetPage={onSetPage}
27 widgetId="offset-pagination-example"
28 onPerPageSelect={onPerPageSelect}
29 ouiaId="PaginationOffset"
30 />
31 );
32 };