@loadsmart/loadsmart-ui 5.3.1 → 5.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/TablePagination/TablePagination.types.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/TablePagination/TablePagination.stories.tsx +6 -1
- package/src/components/TablePagination/TablePagination.test.tsx +0 -1
- package/src/components/TablePagination/TablePagination.tsx +1 -6
- package/src/components/TablePagination/TablePagination.types.ts +3 -0
package/package.json
CHANGED
|
@@ -15,6 +15,11 @@ export const Playground: Story<TablePaginationProps> = (args: TablePaginationPro
|
|
|
15
15
|
const [page, setPage] = useState(args.page)
|
|
16
16
|
const [rowsPerPage, setRowsPerPage] = useState(args.rowsPerPage)
|
|
17
17
|
|
|
18
|
+
const handleRowsPerPageChange = (rowsPerPage: number) => {
|
|
19
|
+
setRowsPerPage(rowsPerPage)
|
|
20
|
+
setPage(0)
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
return (
|
|
19
24
|
<Layout.Group>
|
|
20
25
|
<TablePagination
|
|
@@ -22,7 +27,7 @@ export const Playground: Story<TablePaginationProps> = (args: TablePaginationPro
|
|
|
22
27
|
onPageChange={(page) => setPage(page)}
|
|
23
28
|
page={page}
|
|
24
29
|
rowsPerPage={rowsPerPage}
|
|
25
|
-
onRowsPerPageChange={
|
|
30
|
+
onRowsPerPageChange={handleRowsPerPageChange}
|
|
26
31
|
/>
|
|
27
32
|
</Layout.Group>
|
|
28
33
|
)
|
|
@@ -70,7 +70,6 @@ describe('TablePagination', () => {
|
|
|
70
70
|
userEvent.click(screen.getByText(/50 per page/i))
|
|
71
71
|
|
|
72
72
|
expect(onRowsPerPageChange).toHaveBeenLastCalledWith(50)
|
|
73
|
-
expect(onPageChange).toHaveBeenLastCalledWith(0)
|
|
74
73
|
})
|
|
75
74
|
|
|
76
75
|
it('hides some actions for the compact variant', () => {
|
|
@@ -20,17 +20,12 @@ function TablePagination(props: TablePaginationProps): JSX.Element {
|
|
|
20
20
|
...rest
|
|
21
21
|
} = props
|
|
22
22
|
|
|
23
|
-
const handleRowsPerPageChange = (selectedOption: number) => {
|
|
24
|
-
onRowsPerPageChange(selectedOption)
|
|
25
|
-
onPageChange(0)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
23
|
return (
|
|
29
24
|
<Layout.Group space="xl" align="center" justify="space-between" {...rest}>
|
|
30
25
|
<RowsPerPage
|
|
31
26
|
page={page}
|
|
32
27
|
count={count}
|
|
33
|
-
onRowsPerPageChange={
|
|
28
|
+
onRowsPerPageChange={onRowsPerPageChange}
|
|
34
29
|
rowsPerPage={rowsPerPage}
|
|
35
30
|
rowsPerPageOptions={rowsPerPageOptions}
|
|
36
31
|
labelRowsPerPage={labelRowsPerPage}
|
|
@@ -21,6 +21,9 @@ export interface TablePaginationProps extends GroupProps {
|
|
|
21
21
|
onPageChange: (page: number) => void
|
|
22
22
|
/**
|
|
23
23
|
* Callback fired when the number of rows per page is changed.
|
|
24
|
+
*
|
|
25
|
+
* Note: Resetting the page to zero after the number of rows per page is changed isn't part of
|
|
26
|
+
* the component and has to be implemented where it's necessary
|
|
24
27
|
*/
|
|
25
28
|
onRowsPerPageChange: (rowsPerPage: number) => void
|
|
26
29
|
/**
|