diff --git a/src/components/pagination/table-pagination.tsx b/src/components/pagination/table-pagination.tsx index 5c7fc9f5..36b5d572 100644 --- a/src/components/pagination/table-pagination.tsx +++ b/src/components/pagination/table-pagination.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import cx from 'classnames'; import { useTheme } from 'styled-components'; -import { Text, SelectInput, Button } from 'components'; +import { Text, SelectInput, SelectInputProps, Button } from 'components'; import { usePagination } from './usePagination'; import { StyledPagination } from './styles'; import { additionalStyles } from '../select/style'; @@ -25,8 +25,16 @@ export type TablePaginationProps = { onChangePage: (page: number | PaginationOption) => void; onChangeRowsPerPage: any; page: number; + /** + * used to pass props to the page select input + */ + pageSelectProps?: SelectInputProps; rowsPerPage: number; rowsPerPageOptions?: any; + /** + * used to pass props to the rows per page select input + */ + rowsPerPageSelectProps?: SelectInputProps; selectStyles?: { [key: string]: (...args) => { [k: string]: any }; }; @@ -88,6 +96,8 @@ export const TablePagination = ({ `Displaying ${rangeStart}-${rangeEnd} of ${pCount} items`, currentPage: (currentPage: number, pagesAmount: number) => `${currentPage} of ${pagesAmount} pages`, }, + rowsPerPageSelectProps = {}, + pageSelectProps = {}, ...otherProps }: TablePaginationProps): JSX.Element => { const [isFirst, isLast, pagesAmount] = usePagination({ page, count, rowsPerPage }); @@ -114,6 +124,7 @@ export const TablePagination = ({ {locales.itemsPerPage} ; + +const Template: ComponentStory = (args) => ; + +export const Default = Template.bind({}); + +const DemoTemplate = () => { + const [page, setPage] = React.useState(0); + const [rowsPerPage, setRowsPerPage] = React.useState(12); + + const handleChangePage = (val) => { + setPage(Number(val)); + }; + + const handleChangeRowsPerPage = (val) => { + setRowsPerPage(Number(val)); + setPage(0); + }; + + return ( + + + + + + + + ); +}; + +export const Demo = DemoTemplate.bind({}); diff --git a/stories/pagination/index.jsx b/stories/pagination/index.jsx deleted file mode 100644 index 9ceedb3a..00000000 --- a/stories/pagination/index.jsx +++ /dev/null @@ -1,110 +0,0 @@ -// import React from 'react'; - -// import PaginationReadme from 'components/pagination/README.md'; -// import TablePaginationReadme from 'components/pagination/TABLE-README.md'; -// import PaginationDocs from 'components/pagination/DOCS.md'; -// import TablePaginationDocs from 'components/pagination/TABLE-DOCS.md'; - -// import { Row, Col, Pagination, TablePagination as TablePaginationSelect } from 'components'; - -// import { BrowserRouter } from 'react-router-dom'; - -// import { decorator } from '../../utils/decorator'; -// import { WrappedComponent } from '../helpers/wrapped'; - -// export const TablePagination = decorator('Pagination', TablePaginationDocs, TablePaginationReadme).add( -// 'TablePagination component', -// () => { -// const [page, setPage] = React.useState(0); -// const [rowsPerPage, setRowsPerPage] = React.useState(12); - -// const handleChangePage = (val) => { -// setPage(Number(val)); -// }; - -// const handleChangeRowsPerPage = (val) => { -// setRowsPerPage(Number(val)); -// setPage(0); -// }; - -// return ( -// -// -// -// -// -// -// -// -// -// ); -// }, -// ); - -// export default decorator('Pagination', PaginationDocs, PaginationReadme).add('Pagination component', () => { -// const [page, setPage] = React.useState(0); -// const [rowsPerPage, setRowsPerPage] = React.useState(12); - -// const handleButtonClick = (val) => { -// setPage(val); -// }; - -// return ( -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// ); -// });