File tree 4 files changed +11
-13
lines changed
packages/ui/src/components/Table
4 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import { useState } from "react"
11
11
import { Table } from "flowbite-react";
12
12
13
13
function Component() {
14
- const [pageNo, setPageNo] = useState(1 );
14
+ const [pageNo, setPageNo] = useState(0 );
15
15
16
16
const [rowsPerPage] = useState(10);
17
17
@@ -101,7 +101,7 @@ function Component() {
101
101
` ;
102
102
103
103
function Component ( ) {
104
- const [ pageNo , setPageNo ] = useState ( 1 ) ;
104
+ const [ pageNo , setPageNo ] = useState ( 0 ) ;
105
105
106
106
const [ rowsPerPage ] = useState ( 10 ) ;
107
107
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import { useState } from "react"
11
11
import { Table } from "flowbite-react";
12
12
13
13
function Component() {
14
- const [pageNo, setPageNo] = useState(1 );
14
+ const [pageNo, setPageNo] = useState(0 );
15
15
16
16
const [rowsPerPage] = useState(10);
17
17
@@ -101,7 +101,7 @@ function Component() {
101
101
` ;
102
102
103
103
function Component ( ) {
104
- const [ pageNo , setPageNo ] = useState ( 1 ) ;
104
+ const [ pageNo , setPageNo ] = useState ( 0 ) ;
105
105
106
106
const [ rowsPerPage ] = useState ( 10 ) ;
107
107
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ export const DefaultTable = Template.bind({});
89
89
DefaultTable . storyName = "Default" ;
90
90
91
91
const TPageNumberTemplate : StoryFn < TableProps > = ( args ) => {
92
- const [ pageNo , setPageNo ] = useState ( 1 ) ;
92
+ const [ pageNo , setPageNo ] = useState ( 0 ) ;
93
93
const [ rowsPerPage ] = useState ( 10 ) ;
94
94
95
95
const handlePageChange = ( newPage : number ) => setPageNo ( newPage ) ;
@@ -189,7 +189,7 @@ export const PaginationNumberTable = TPageNumberTemplate.bind({});
189
189
PaginationNumberTable . storyName = "Pagination with Numbers" ;
190
190
191
191
const TPageButtonTemplate : StoryFn < TableProps > = ( args ) => {
192
- const [ pageNo , setPageNo ] = useState ( 1 ) ;
192
+ const [ pageNo , setPageNo ] = useState ( 0 ) ;
193
193
const [ rowsPerPage ] = useState ( 10 ) ;
194
194
195
195
const handlePageChange = ( newPage : number ) => setPageNo ( newPage ) ;
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ export const TablePagination = forwardRef<HTMLDivElement, TablePaginationProps>(
50
50
const pageNumbers = [ ...Array ( nPages + 1 ) . keys ( ) ] . slice ( 1 ) ;
51
51
52
52
const goToPrevPage = ( ) : void => {
53
- if ( page !== 1 ) {
53
+ if ( page !== 0 ) {
54
54
onPageChange ( page - 1 ) ;
55
55
}
56
56
} ;
@@ -87,19 +87,17 @@ export const TablePagination = forwardRef<HTMLDivElement, TablePaginationProps>(
87
87
</ span >
88
88
89
89
< ul className = { theme . page . base } >
90
- < button onClick = { goToPrevPage } className = { theme . page . previous } disabled = { page === 1 } >
90
+ < button onClick = { goToPrevPage } className = { theme . page . previous } disabled = { page === 0 } >
91
91
Previous
92
92
</ button >
93
93
{ paginationType === "numbers" ? (
94
94
< >
95
95
{ pageNumbers . map ( ( pgNumber , index ) => {
96
96
return (
97
97
< button
98
- onClick = { ( ) => {
99
- directPageChange ( index + 1 ) ;
100
- } }
101
- key = { index + 1 }
102
- className = { twMerge ( theme . page . pageNo , index + 1 === page ? "bg-blue-50 text-blue-600" : "" ) }
98
+ onClick = { ( ) => directPageChange ( index ) }
99
+ key = { index }
100
+ className = { twMerge ( theme . page . pageNo , index === page ? "bg-blue-50 text-blue-600" : "" ) }
103
101
>
104
102
{ pgNumber }
105
103
</ button >
You can’t perform that action at this time.
0 commit comments