@dt-dds/react-pagination 1.0.0-beta.47 → 1.0.0-beta.49
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/CHANGELOG.md +27 -0
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +126 -53
- package/dist/index.mjs +127 -54
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @dt-ui/react-pagination
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.49
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: dropdown documentation
|
|
8
|
+
- chore: update to ESLint 10
|
|
9
|
+
- chore: update to ESLint 9
|
|
10
|
+
- fix: default icon type in themes
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @dt-dds/react-select@1.0.0-beta.98
|
|
16
|
+
- @dt-dds/icons@1.0.0-beta.7
|
|
17
|
+
- @dt-dds/react-core@1.0.0-beta.60
|
|
18
|
+
- @dt-dds/react-tooltip@1.0.0-beta.70
|
|
19
|
+
- @dt-dds/react-icon@1.0.0-beta.64
|
|
20
|
+
- @dt-dds/react-typography@1.0.0-beta.51
|
|
21
|
+
- @dt-dds/themes@1.0.0-beta.15
|
|
22
|
+
|
|
23
|
+
## 1.0.0-beta.48
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- fix: pagination render
|
|
28
|
+
- refactor: backwards and forward pagination
|
|
29
|
+
|
|
3
30
|
## 1.0.0-beta.47
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -31,7 +31,15 @@ declare const FIRST_PAGE = 1;
|
|
|
31
31
|
declare const PAGINATION_BUTTON_SIZES = 24;
|
|
32
32
|
declare const ITEMS_PER_PAGE_WIDTH = 200;
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
interface PageRenderData {
|
|
35
|
+
shouldRenderFirstPage: boolean;
|
|
36
|
+
shouldRenderLastPage: boolean;
|
|
37
|
+
shouldRenderLeftEllipsis: boolean;
|
|
38
|
+
shouldRenderRightEllipsis: boolean;
|
|
39
|
+
pages: number[];
|
|
40
|
+
}
|
|
41
|
+
type PaginationDirection = 'FORWARD' | 'BACKWARD';
|
|
42
|
+
declare const getPageNumbers: (currentPage: number, lastPage: number, direction?: PaginationDirection) => PageRenderData;
|
|
35
43
|
|
|
36
44
|
declare module '@emotion/react' {
|
|
37
45
|
interface Theme extends CustomTheme {
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,15 @@ declare const FIRST_PAGE = 1;
|
|
|
31
31
|
declare const PAGINATION_BUTTON_SIZES = 24;
|
|
32
32
|
declare const ITEMS_PER_PAGE_WIDTH = 200;
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
interface PageRenderData {
|
|
35
|
+
shouldRenderFirstPage: boolean;
|
|
36
|
+
shouldRenderLastPage: boolean;
|
|
37
|
+
shouldRenderLeftEllipsis: boolean;
|
|
38
|
+
shouldRenderRightEllipsis: boolean;
|
|
39
|
+
pages: number[];
|
|
40
|
+
}
|
|
41
|
+
type PaginationDirection = 'FORWARD' | 'BACKWARD';
|
|
42
|
+
declare const getPageNumbers: (currentPage: number, lastPage: number, direction?: PaginationDirection) => PageRenderData;
|
|
35
43
|
|
|
36
44
|
declare module '@emotion/react' {
|
|
37
45
|
interface Theme extends CustomTheme {
|
package/dist/index.js
CHANGED
|
@@ -221,35 +221,98 @@ var PaginationNavButton = ({
|
|
|
221
221
|
PaginationNavButton.displayName = "PaginationNavButton";
|
|
222
222
|
|
|
223
223
|
// src/utils/getPageNumbers.ts
|
|
224
|
-
var
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
224
|
+
var getCompactPageNumbers = (firstPage, lastPage) => ({
|
|
225
|
+
pages: Array.from(
|
|
226
|
+
{ length: Math.max(lastPage - firstPage + 1, 0) },
|
|
227
|
+
(_, index) => firstPage + index
|
|
228
|
+
),
|
|
229
|
+
shouldRenderFirstPage: false,
|
|
230
|
+
shouldRenderLastPage: false,
|
|
231
|
+
shouldRenderLeftEllipsis: false,
|
|
232
|
+
shouldRenderRightEllipsis: false
|
|
233
|
+
});
|
|
234
|
+
var getForwardPageNumbers = (currentPage, firstPage, lastPage) => {
|
|
235
|
+
if (currentPage <= firstPage + 1) {
|
|
236
|
+
return {
|
|
237
|
+
pages: [firstPage, firstPage + 1, firstPage + 2],
|
|
238
|
+
shouldRenderFirstPage: false,
|
|
239
|
+
shouldRenderLastPage: true,
|
|
240
|
+
shouldRenderLeftEllipsis: false,
|
|
241
|
+
shouldRenderRightEllipsis: true
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (currentPage <= lastPage - 3) {
|
|
245
|
+
return {
|
|
246
|
+
pages: [currentPage - 1, currentPage, currentPage + 1],
|
|
247
|
+
shouldRenderFirstPage: false,
|
|
248
|
+
shouldRenderLastPage: true,
|
|
249
|
+
shouldRenderLeftEllipsis: false,
|
|
250
|
+
shouldRenderRightEllipsis: true
|
|
251
|
+
};
|
|
231
252
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
253
|
+
return {
|
|
254
|
+
pages: [lastPage - 2, lastPage - 1, lastPage],
|
|
255
|
+
shouldRenderFirstPage: true,
|
|
256
|
+
shouldRenderLastPage: false,
|
|
257
|
+
shouldRenderLeftEllipsis: true,
|
|
258
|
+
shouldRenderRightEllipsis: false
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
var getBackwardPageNumbers = (currentPage, firstPage, lastPage) => {
|
|
262
|
+
if (currentPage <= firstPage + 2) {
|
|
263
|
+
return {
|
|
264
|
+
pages: [firstPage, firstPage + 1, firstPage + 2],
|
|
265
|
+
shouldRenderFirstPage: false,
|
|
266
|
+
shouldRenderLastPage: true,
|
|
267
|
+
shouldRenderLeftEllipsis: false,
|
|
268
|
+
shouldRenderRightEllipsis: true
|
|
269
|
+
};
|
|
236
270
|
}
|
|
237
|
-
if (
|
|
238
|
-
return
|
|
271
|
+
if (currentPage >= lastPage - 1) {
|
|
272
|
+
return {
|
|
273
|
+
pages: [lastPage - 2, lastPage - 1, lastPage],
|
|
274
|
+
shouldRenderFirstPage: true,
|
|
275
|
+
shouldRenderLastPage: false,
|
|
276
|
+
shouldRenderLeftEllipsis: true,
|
|
277
|
+
shouldRenderRightEllipsis: false
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
pages: [currentPage - 1, currentPage, currentPage + 1],
|
|
282
|
+
shouldRenderFirstPage: true,
|
|
283
|
+
shouldRenderLastPage: false,
|
|
284
|
+
shouldRenderLeftEllipsis: true,
|
|
285
|
+
shouldRenderRightEllipsis: false
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
var getPageNumbers = (currentPage, lastPage, direction = "FORWARD") => {
|
|
289
|
+
const firstPage = FIRST_PAGE;
|
|
290
|
+
const cursor = Math.max(Math.min(currentPage, lastPage), firstPage);
|
|
291
|
+
if (lastPage <= firstPage + 4) {
|
|
292
|
+
return getCompactPageNumbers(firstPage, lastPage);
|
|
293
|
+
}
|
|
294
|
+
if (direction === "BACKWARD") {
|
|
295
|
+
return getBackwardPageNumbers(cursor, firstPage, lastPage);
|
|
296
|
+
} else {
|
|
297
|
+
return getForwardPageNumbers(cursor, firstPage, lastPage);
|
|
239
298
|
}
|
|
240
|
-
return [
|
|
241
|
-
1,
|
|
242
|
-
"ellipsis",
|
|
243
|
-
currentPage - NEIGHBOR_COUNT,
|
|
244
|
-
currentPage,
|
|
245
|
-
currentPage + NEIGHBOR_COUNT,
|
|
246
|
-
"ellipsis",
|
|
247
|
-
totalPages
|
|
248
|
-
];
|
|
249
299
|
};
|
|
250
300
|
|
|
251
301
|
// src/Pagination.tsx
|
|
252
302
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
303
|
+
var renderPage = (page, isCurrentPage, handleClick) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
304
|
+
PaginationPageButtonStyled,
|
|
305
|
+
{
|
|
306
|
+
$isActive: isCurrentPage,
|
|
307
|
+
"aria-current": isCurrentPage ? "page" : false,
|
|
308
|
+
"aria-label": `Go to page ${page}`,
|
|
309
|
+
"data-testid": isCurrentPage ? "pagination-current-page" : `pagination-page-${page}`,
|
|
310
|
+
onClick: () => handleClick(page),
|
|
311
|
+
title: `Go to page ${page}`,
|
|
312
|
+
children: page
|
|
313
|
+
},
|
|
314
|
+
page
|
|
315
|
+
);
|
|
253
316
|
var Pagination = ({
|
|
254
317
|
currentPage,
|
|
255
318
|
totalPages,
|
|
@@ -262,12 +325,26 @@ var Pagination = ({
|
|
|
262
325
|
itemsPerPageOptions = ITEMS_PER_PAGE_OPTIONS,
|
|
263
326
|
dataTestId
|
|
264
327
|
}) => {
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
328
|
+
const LAST_PAGE = totalPages;
|
|
329
|
+
const previousPageRef = (0, import_react.useRef)(currentPage);
|
|
330
|
+
const paginationDirection = (
|
|
331
|
+
// eslint-disable-next-line react-hooks/refs
|
|
332
|
+
currentPage < previousPageRef.current ? "BACKWARD" : "FORWARD"
|
|
268
333
|
);
|
|
334
|
+
(0, import_react.useEffect)(() => {
|
|
335
|
+
if (currentPage < 2 || currentPage > LAST_PAGE - 1) {
|
|
336
|
+
previousPageRef.current = currentPage;
|
|
337
|
+
}
|
|
338
|
+
}, [currentPage, LAST_PAGE]);
|
|
339
|
+
const isLastPage = currentPage === LAST_PAGE;
|
|
269
340
|
const isFirstPage = currentPage === FIRST_PAGE;
|
|
270
|
-
const
|
|
341
|
+
const {
|
|
342
|
+
pages,
|
|
343
|
+
shouldRenderFirstPage,
|
|
344
|
+
shouldRenderLastPage,
|
|
345
|
+
shouldRenderLeftEllipsis,
|
|
346
|
+
shouldRenderRightEllipsis
|
|
347
|
+
} = getPageNumbers(currentPage, LAST_PAGE, paginationDirection);
|
|
271
348
|
const itemsBeforeCurrentPage = (currentPage - FIRST_PAGE) * itemsPerPage;
|
|
272
349
|
const remainingItems = Math.max(
|
|
273
350
|
0,
|
|
@@ -277,12 +354,12 @@ var Pagination = ({
|
|
|
277
354
|
const hasInfoSection = showItemsPerPage || showItemsInfo && totalItems !== void 0;
|
|
278
355
|
const handlePageChange = (0, import_react.useCallback)(
|
|
279
356
|
(page) => {
|
|
280
|
-
const canNavigateToPage = page !== currentPage && page >= FIRST_PAGE && page <=
|
|
357
|
+
const canNavigateToPage = page !== currentPage && page >= FIRST_PAGE && page <= LAST_PAGE;
|
|
281
358
|
if (canNavigateToPage) {
|
|
282
359
|
onPageChange(page);
|
|
283
360
|
}
|
|
284
361
|
},
|
|
285
|
-
[currentPage,
|
|
362
|
+
[currentPage, LAST_PAGE, onPageChange]
|
|
286
363
|
);
|
|
287
364
|
const handleItemsPerPageChange = (0, import_react.useCallback)(
|
|
288
365
|
(value) => {
|
|
@@ -351,31 +428,27 @@ var Pagination = ({
|
|
|
351
428
|
tooltipLabel: "Previous page"
|
|
352
429
|
}
|
|
353
430
|
),
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
page
|
|
377
|
-
);
|
|
378
|
-
}),
|
|
431
|
+
shouldRenderFirstPage ? renderPage(FIRST_PAGE, isFirstPage, handlePageChange) : null,
|
|
432
|
+
shouldRenderLeftEllipsis ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
433
|
+
TruncationTextStyled,
|
|
434
|
+
{
|
|
435
|
+
"data-testid": "pagination-ellipsis",
|
|
436
|
+
children: "..."
|
|
437
|
+
},
|
|
438
|
+
"ellipsis-left"
|
|
439
|
+
) : null,
|
|
440
|
+
pages.map(
|
|
441
|
+
(page) => renderPage(page, page === currentPage, handlePageChange)
|
|
442
|
+
),
|
|
443
|
+
shouldRenderRightEllipsis ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
444
|
+
TruncationTextStyled,
|
|
445
|
+
{
|
|
446
|
+
"data-testid": "pagination-ellipsis",
|
|
447
|
+
children: "..."
|
|
448
|
+
},
|
|
449
|
+
"ellipsis-right"
|
|
450
|
+
) : null,
|
|
451
|
+
shouldRenderLastPage ? renderPage(LAST_PAGE, isLastPage, handlePageChange) : null,
|
|
379
452
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
380
453
|
PaginationNavButton,
|
|
381
454
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/Pagination.tsx
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3
3
|
import { Select } from "@dt-dds/react-select";
|
|
4
4
|
|
|
5
5
|
// src/components/PaginationNavButton/PaginationNavButton.tsx
|
|
@@ -180,35 +180,98 @@ var PaginationNavButton = ({
|
|
|
180
180
|
PaginationNavButton.displayName = "PaginationNavButton";
|
|
181
181
|
|
|
182
182
|
// src/utils/getPageNumbers.ts
|
|
183
|
-
var
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
183
|
+
var getCompactPageNumbers = (firstPage, lastPage) => ({
|
|
184
|
+
pages: Array.from(
|
|
185
|
+
{ length: Math.max(lastPage - firstPage + 1, 0) },
|
|
186
|
+
(_, index) => firstPage + index
|
|
187
|
+
),
|
|
188
|
+
shouldRenderFirstPage: false,
|
|
189
|
+
shouldRenderLastPage: false,
|
|
190
|
+
shouldRenderLeftEllipsis: false,
|
|
191
|
+
shouldRenderRightEllipsis: false
|
|
192
|
+
});
|
|
193
|
+
var getForwardPageNumbers = (currentPage, firstPage, lastPage) => {
|
|
194
|
+
if (currentPage <= firstPage + 1) {
|
|
195
|
+
return {
|
|
196
|
+
pages: [firstPage, firstPage + 1, firstPage + 2],
|
|
197
|
+
shouldRenderFirstPage: false,
|
|
198
|
+
shouldRenderLastPage: true,
|
|
199
|
+
shouldRenderLeftEllipsis: false,
|
|
200
|
+
shouldRenderRightEllipsis: true
|
|
201
|
+
};
|
|
190
202
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
203
|
+
if (currentPage <= lastPage - 3) {
|
|
204
|
+
return {
|
|
205
|
+
pages: [currentPage - 1, currentPage, currentPage + 1],
|
|
206
|
+
shouldRenderFirstPage: false,
|
|
207
|
+
shouldRenderLastPage: true,
|
|
208
|
+
shouldRenderLeftEllipsis: false,
|
|
209
|
+
shouldRenderRightEllipsis: true
|
|
210
|
+
};
|
|
195
211
|
}
|
|
196
|
-
|
|
197
|
-
|
|
212
|
+
return {
|
|
213
|
+
pages: [lastPage - 2, lastPage - 1, lastPage],
|
|
214
|
+
shouldRenderFirstPage: true,
|
|
215
|
+
shouldRenderLastPage: false,
|
|
216
|
+
shouldRenderLeftEllipsis: true,
|
|
217
|
+
shouldRenderRightEllipsis: false
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
var getBackwardPageNumbers = (currentPage, firstPage, lastPage) => {
|
|
221
|
+
if (currentPage <= firstPage + 2) {
|
|
222
|
+
return {
|
|
223
|
+
pages: [firstPage, firstPage + 1, firstPage + 2],
|
|
224
|
+
shouldRenderFirstPage: false,
|
|
225
|
+
shouldRenderLastPage: true,
|
|
226
|
+
shouldRenderLeftEllipsis: false,
|
|
227
|
+
shouldRenderRightEllipsis: true
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
if (currentPage >= lastPage - 1) {
|
|
231
|
+
return {
|
|
232
|
+
pages: [lastPage - 2, lastPage - 1, lastPage],
|
|
233
|
+
shouldRenderFirstPage: true,
|
|
234
|
+
shouldRenderLastPage: false,
|
|
235
|
+
shouldRenderLeftEllipsis: true,
|
|
236
|
+
shouldRenderRightEllipsis: false
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
pages: [currentPage - 1, currentPage, currentPage + 1],
|
|
241
|
+
shouldRenderFirstPage: true,
|
|
242
|
+
shouldRenderLastPage: false,
|
|
243
|
+
shouldRenderLeftEllipsis: true,
|
|
244
|
+
shouldRenderRightEllipsis: false
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
var getPageNumbers = (currentPage, lastPage, direction = "FORWARD") => {
|
|
248
|
+
const firstPage = FIRST_PAGE;
|
|
249
|
+
const cursor = Math.max(Math.min(currentPage, lastPage), firstPage);
|
|
250
|
+
if (lastPage <= firstPage + 4) {
|
|
251
|
+
return getCompactPageNumbers(firstPage, lastPage);
|
|
252
|
+
}
|
|
253
|
+
if (direction === "BACKWARD") {
|
|
254
|
+
return getBackwardPageNumbers(cursor, firstPage, lastPage);
|
|
255
|
+
} else {
|
|
256
|
+
return getForwardPageNumbers(cursor, firstPage, lastPage);
|
|
198
257
|
}
|
|
199
|
-
return [
|
|
200
|
-
1,
|
|
201
|
-
"ellipsis",
|
|
202
|
-
currentPage - NEIGHBOR_COUNT,
|
|
203
|
-
currentPage,
|
|
204
|
-
currentPage + NEIGHBOR_COUNT,
|
|
205
|
-
"ellipsis",
|
|
206
|
-
totalPages
|
|
207
|
-
];
|
|
208
258
|
};
|
|
209
259
|
|
|
210
260
|
// src/Pagination.tsx
|
|
211
261
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
262
|
+
var renderPage = (page, isCurrentPage, handleClick) => /* @__PURE__ */ jsx2(
|
|
263
|
+
PaginationPageButtonStyled,
|
|
264
|
+
{
|
|
265
|
+
$isActive: isCurrentPage,
|
|
266
|
+
"aria-current": isCurrentPage ? "page" : false,
|
|
267
|
+
"aria-label": `Go to page ${page}`,
|
|
268
|
+
"data-testid": isCurrentPage ? "pagination-current-page" : `pagination-page-${page}`,
|
|
269
|
+
onClick: () => handleClick(page),
|
|
270
|
+
title: `Go to page ${page}`,
|
|
271
|
+
children: page
|
|
272
|
+
},
|
|
273
|
+
page
|
|
274
|
+
);
|
|
212
275
|
var Pagination = ({
|
|
213
276
|
currentPage,
|
|
214
277
|
totalPages,
|
|
@@ -221,12 +284,26 @@ var Pagination = ({
|
|
|
221
284
|
itemsPerPageOptions = ITEMS_PER_PAGE_OPTIONS,
|
|
222
285
|
dataTestId
|
|
223
286
|
}) => {
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
287
|
+
const LAST_PAGE = totalPages;
|
|
288
|
+
const previousPageRef = useRef(currentPage);
|
|
289
|
+
const paginationDirection = (
|
|
290
|
+
// eslint-disable-next-line react-hooks/refs
|
|
291
|
+
currentPage < previousPageRef.current ? "BACKWARD" : "FORWARD"
|
|
227
292
|
);
|
|
293
|
+
useEffect(() => {
|
|
294
|
+
if (currentPage < 2 || currentPage > LAST_PAGE - 1) {
|
|
295
|
+
previousPageRef.current = currentPage;
|
|
296
|
+
}
|
|
297
|
+
}, [currentPage, LAST_PAGE]);
|
|
298
|
+
const isLastPage = currentPage === LAST_PAGE;
|
|
228
299
|
const isFirstPage = currentPage === FIRST_PAGE;
|
|
229
|
-
const
|
|
300
|
+
const {
|
|
301
|
+
pages,
|
|
302
|
+
shouldRenderFirstPage,
|
|
303
|
+
shouldRenderLastPage,
|
|
304
|
+
shouldRenderLeftEllipsis,
|
|
305
|
+
shouldRenderRightEllipsis
|
|
306
|
+
} = getPageNumbers(currentPage, LAST_PAGE, paginationDirection);
|
|
230
307
|
const itemsBeforeCurrentPage = (currentPage - FIRST_PAGE) * itemsPerPage;
|
|
231
308
|
const remainingItems = Math.max(
|
|
232
309
|
0,
|
|
@@ -236,12 +313,12 @@ var Pagination = ({
|
|
|
236
313
|
const hasInfoSection = showItemsPerPage || showItemsInfo && totalItems !== void 0;
|
|
237
314
|
const handlePageChange = useCallback(
|
|
238
315
|
(page) => {
|
|
239
|
-
const canNavigateToPage = page !== currentPage && page >= FIRST_PAGE && page <=
|
|
316
|
+
const canNavigateToPage = page !== currentPage && page >= FIRST_PAGE && page <= LAST_PAGE;
|
|
240
317
|
if (canNavigateToPage) {
|
|
241
318
|
onPageChange(page);
|
|
242
319
|
}
|
|
243
320
|
},
|
|
244
|
-
[currentPage,
|
|
321
|
+
[currentPage, LAST_PAGE, onPageChange]
|
|
245
322
|
);
|
|
246
323
|
const handleItemsPerPageChange = useCallback(
|
|
247
324
|
(value) => {
|
|
@@ -310,31 +387,27 @@ var Pagination = ({
|
|
|
310
387
|
tooltipLabel: "Previous page"
|
|
311
388
|
}
|
|
312
389
|
),
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
},
|
|
335
|
-
page
|
|
336
|
-
);
|
|
337
|
-
}),
|
|
390
|
+
shouldRenderFirstPage ? renderPage(FIRST_PAGE, isFirstPage, handlePageChange) : null,
|
|
391
|
+
shouldRenderLeftEllipsis ? /* @__PURE__ */ jsx2(
|
|
392
|
+
TruncationTextStyled,
|
|
393
|
+
{
|
|
394
|
+
"data-testid": "pagination-ellipsis",
|
|
395
|
+
children: "..."
|
|
396
|
+
},
|
|
397
|
+
"ellipsis-left"
|
|
398
|
+
) : null,
|
|
399
|
+
pages.map(
|
|
400
|
+
(page) => renderPage(page, page === currentPage, handlePageChange)
|
|
401
|
+
),
|
|
402
|
+
shouldRenderRightEllipsis ? /* @__PURE__ */ jsx2(
|
|
403
|
+
TruncationTextStyled,
|
|
404
|
+
{
|
|
405
|
+
"data-testid": "pagination-ellipsis",
|
|
406
|
+
children: "..."
|
|
407
|
+
},
|
|
408
|
+
"ellipsis-right"
|
|
409
|
+
) : null,
|
|
410
|
+
shouldRenderLastPage ? renderPage(LAST_PAGE, isLastPage, handlePageChange) : null,
|
|
338
411
|
/* @__PURE__ */ jsx2(
|
|
339
412
|
PaginationNavButton,
|
|
340
413
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dt-dds/react-pagination",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.49",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js"
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"test:update:snapshot": "jest -u"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dt-dds/react-core": "1.0.0-beta.
|
|
24
|
-
"@dt-dds/react-typography": "1.0.0-beta.
|
|
25
|
-
"@dt-dds/react-icon": "1.0.0-beta.
|
|
26
|
-
"@dt-dds/icons": "1.0.0-beta.
|
|
27
|
-
"@dt-dds/react-select": "1.0.0-beta.
|
|
28
|
-
"@dt-dds/react-tooltip": "1.0.0-beta.
|
|
29
|
-
"@dt-dds/themes": "1.0.0-beta.
|
|
23
|
+
"@dt-dds/react-core": "1.0.0-beta.60",
|
|
24
|
+
"@dt-dds/react-typography": "1.0.0-beta.51",
|
|
25
|
+
"@dt-dds/react-icon": "1.0.0-beta.64",
|
|
26
|
+
"@dt-dds/icons": "1.0.0-beta.7",
|
|
27
|
+
"@dt-dds/react-select": "1.0.0-beta.98",
|
|
28
|
+
"@dt-dds/react-tooltip": "1.0.0-beta.70",
|
|
29
|
+
"@dt-dds/themes": "1.0.0-beta.15"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@babel/core": "^7.22.9",
|