@andreagiugni/tailwind-dashboard-ui 1.0.29 → 1.0.30
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/index.cjs +31 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -544,36 +544,48 @@ var justifyByAlign = {
|
|
|
544
544
|
center: "justify-center",
|
|
545
545
|
right: "justify-end"
|
|
546
546
|
};
|
|
547
|
+
var getPaginationItems = (currentPage, totalPages) => {
|
|
548
|
+
const total = Math.max(1, totalPages);
|
|
549
|
+
const current = Math.min(Math.max(currentPage, 1), total);
|
|
550
|
+
if (total <= 3) {
|
|
551
|
+
return Array.from({ length: total }, (_, i) => i + 1);
|
|
552
|
+
}
|
|
553
|
+
if (current === 1) {
|
|
554
|
+
return [1, 2, "ellipsis", total];
|
|
555
|
+
}
|
|
556
|
+
if (current === total) {
|
|
557
|
+
return [1, "ellipsis", total - 1, total];
|
|
558
|
+
}
|
|
559
|
+
return [current - 1, current, current + 1];
|
|
560
|
+
};
|
|
547
561
|
var Pagination = ({
|
|
548
562
|
currentPage,
|
|
549
563
|
totalPages,
|
|
550
564
|
onPageChange,
|
|
551
565
|
align
|
|
552
566
|
}) => {
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
);
|
|
567
|
+
const total = Math.max(1, totalPages);
|
|
568
|
+
const current = Math.min(Math.max(currentPage, 1), total);
|
|
569
|
+
const paginationItems = getPaginationItems(current, total);
|
|
557
570
|
const prev = /* @__PURE__ */ jsxRuntime.jsx(
|
|
558
571
|
"button",
|
|
559
572
|
{
|
|
560
|
-
onClick: () => onPageChange(
|
|
561
|
-
disabled:
|
|
573
|
+
onClick: () => onPageChange(current - 1),
|
|
574
|
+
disabled: current === 1,
|
|
562
575
|
"aria-label": "Previous",
|
|
563
576
|
className: navButton,
|
|
564
577
|
children: "Previous"
|
|
565
578
|
}
|
|
566
579
|
);
|
|
567
|
-
const indices = /* @__PURE__ */ jsxRuntime.
|
|
568
|
-
|
|
569
|
-
pagesAroundCurrent.map((page) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
580
|
+
const indices = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: paginationItems.map(
|
|
581
|
+
(item, index) => item === "ellipsis" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "px-2 text-gray-500 dark:text-gray-400", children: "..." }, `ellipsis-${index}`) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
570
582
|
"button",
|
|
571
583
|
{
|
|
572
|
-
onClick: () => onPageChange(
|
|
573
|
-
"aria-current":
|
|
584
|
+
onClick: () => onPageChange(item),
|
|
585
|
+
"aria-current": current === item ? "page" : void 0,
|
|
574
586
|
className: chunkYERNSNT4_cjs.cn(
|
|
575
|
-
"flex w-10 items-center justify-center
|
|
576
|
-
|
|
587
|
+
"flex h-10 w-10 items-center justify-center rounded-lg text-sm font-medium",
|
|
588
|
+
current === item ? (
|
|
577
589
|
// active page keeps its color on hover (no hover restyle)
|
|
578
590
|
"bg-brand-500 text-white"
|
|
579
591
|
) : (
|
|
@@ -581,17 +593,16 @@ var Pagination = ({
|
|
|
581
593
|
"text-gray-700 hover:bg-blue-500/[0.08] hover:text-brand-500 dark:text-gray-400 dark:hover:text-brand-500"
|
|
582
594
|
)
|
|
583
595
|
),
|
|
584
|
-
children:
|
|
596
|
+
children: item
|
|
585
597
|
},
|
|
586
|
-
|
|
587
|
-
)
|
|
588
|
-
|
|
589
|
-
] });
|
|
598
|
+
item
|
|
599
|
+
)
|
|
600
|
+
) });
|
|
590
601
|
const next = /* @__PURE__ */ jsxRuntime.jsx(
|
|
591
602
|
"button",
|
|
592
603
|
{
|
|
593
|
-
onClick: () => onPageChange(
|
|
594
|
-
disabled:
|
|
604
|
+
onClick: () => onPageChange(current + 1),
|
|
605
|
+
disabled: current === total,
|
|
595
606
|
"aria-label": "Next",
|
|
596
607
|
className: navButton,
|
|
597
608
|
children: "Next"
|