Debian Codegraph @

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

raw
1 import { Fragment, useState } from 'react';
2 import { Pagination } from '@patternfly/react-core';
3
4 export const PaginationIndeterminate: React.FunctionComponent = () => {
5 const [page, setPage] = useState(1);
6 const [perPage, setPerPage] = useState(20);
7
8 const onSetPage = (_event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => {
9 setPage(newPage);
10 };
11
12 const onPerPageSelect = (
13 _event: React.MouseEvent | React.KeyboardEvent | MouseEvent,
14 newPerPage: number,
15 newPage: number
16 ) => {
17 setPerPage(newPerPage);
18 setPage(newPage);
19 };
20
21 return (
22 <Pagination
23 toggleTemplate={({ firstIndex, lastIndex }) => (
24 <Fragment>
25 <b>
26 {firstIndex} - {lastIndex}
27 </b>
28 of
29 <b>many</b>
30 </Fragment>
31 )}
32 widgetId="indeterminate-example"
33 perPage={perPage}
34 page={page}
35 onSetPage={onSetPage}
36 onPerPageSelect={onPerPageSelect}
37 />
38 );
39 };