Skip to content

Commit b17c7f5

Browse files
committed
Feat: Pagination option last and first page
1 parent 5844212 commit b17c7f5

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

src/DataTable/Pagination.tsx

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const defaultComponentOptions = {
1515
noRowsPerPage: false,
1616
selectAllRowsItem: false,
1717
selectAllRowsItemText: 'All',
18+
firstPage: true,
19+
lastPage: true,
1820
};
1921

2022
const PaginationWrapper = styled.nav`
@@ -150,17 +152,19 @@ function Pagination({
150152
)}
151153
{shouldShow && <Range>{range}</Range>}
152154
<PageList>
153-
<Button
154-
id="pagination-first-page"
155-
type="button"
156-
aria-label="First Page"
157-
aria-disabled={disabledLesser}
158-
onClick={handleFirst}
159-
disabled={disabledLesser}
160-
isRTL={isRTL}
161-
>
162-
{paginationIconFirstPage}
163-
</Button>
155+
{options.firstPage && (
156+
<Button
157+
id="pagination-first-page"
158+
type="button"
159+
aria-label="First Page"
160+
aria-disabled={disabledLesser}
161+
onClick={handleFirst}
162+
disabled={disabledLesser}
163+
isRTL={isRTL}
164+
>
165+
{paginationIconFirstPage}
166+
</Button>
167+
)}
164168

165169
<Button
166170
id="pagination-previous-page"
@@ -188,17 +192,19 @@ function Pagination({
188192
{paginationIconNext}
189193
</Button>
190194

191-
<Button
192-
id="pagination-last-page"
193-
type="button"
194-
aria-label="Last Page"
195-
aria-disabled={disabledGreater}
196-
onClick={handleLast}
197-
disabled={disabledGreater}
198-
isRTL={isRTL}
199-
>
200-
{paginationIconLastPage}
201-
</Button>
195+
{options.lastPage && (
196+
<Button
197+
id="pagination-last-page"
198+
type="button"
199+
aria-label="Last Page"
200+
aria-disabled={disabledGreater}
201+
onClick={handleLast}
202+
disabled={disabledGreater}
203+
isRTL={isRTL}
204+
>
205+
{paginationIconLastPage}
206+
</Button>
207+
)}
202208
</PageList>
203209
</PaginationWrapper>
204210
);

src/DataTable/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ export interface PaginationOptions {
222222
rangeSeparatorText?: string;
223223
selectAllRowsItem?: boolean;
224224
selectAllRowsItemText?: string;
225+
firstPage?: boolean;
226+
lastPage?: boolean;
225227
}
226228

227229
export interface PaginationServerOptions {

0 commit comments

Comments
 (0)