tw-react-components 0.0.168 → 0.0.170
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/index.esm.js +4 -2
- package/package.json +1 -1
package/index.esm.js
CHANGED
|
@@ -748,6 +748,8 @@ function useOutsideClick(ref, callback) {
|
|
|
748
748
|
|
|
749
749
|
function usePagination(currentIndex, totalPages) {
|
|
750
750
|
return useMemo(() => {
|
|
751
|
+
if (totalPages === 0)
|
|
752
|
+
return [];
|
|
751
753
|
const result = [];
|
|
752
754
|
result.push(Math.min(currentIndex, totalPages));
|
|
753
755
|
if (totalPages > 7 && currentIndex > 4) {
|
|
@@ -1485,9 +1487,9 @@ const Pagination = ({ disabled, pageSize = 10, currentPage, totalItems, dataTest
|
|
|
1485
1487
|
useEffect(() => {
|
|
1486
1488
|
setCurrentPage((page) => Math.min(page, Math.max(0, totalPages - 1)));
|
|
1487
1489
|
}, [setCurrentPage, totalPages]);
|
|
1488
|
-
return (jsx(Flex, { justify: "end", dataTestId: dataTestId, children: jsxs(Flex, { className: "h-9 gap-0 divide-x rounded-md border border-slate-300 bg-white dark:divide-slate-700 dark:border-slate-700 dark:bg-slate-800", children: [jsx(PaginationItem, { title: "First page", onClick: () => setCurrentPage(0), disabled: !currentPage || disabled, dataTestId: `${dataTestId}-first-page`, children: jsx(ChevronsLeftIcon, { className: "h-4 w-4" }) }), jsx(PaginationItem, { title: "Previous page", onClick: () => currentPage && setCurrentPage(currentPage - 1), disabled: !currentPage || disabled, dataTestId: `${dataTestId}-previous-page`, children: jsx(ChevronLeftIcon, { className: "h-4 w-4" }) }), pagination.map((page, index) => (jsx(PaginationItem, { active: page !== '...' && page - 1 === currentPage, title: page !== '...' ? `Page ${page}` : undefined, onClick: page !== '...' ? () => setCurrentPage(page - 1) : undefined, disabled: page === '...' || disabled, dataTestId: `${dataTestId}-page-${page}`, children: page }, index))), jsx(PaginationItem, { title: "Next page", onClick: () => currentPage + 1 < totalPages && setCurrentPage(currentPage + 1), disabled: currentPage + 1 === totalPages || disabled, dataTestId: `${dataTestId}-next-page`, children: jsx(ChevronRightIcon, { className: "h-4 w-4" }) }), jsx(PaginationItem, { title: "Last page", onClick: () => setCurrentPage(Math.floor(totalItems && !(totalItems % pageSize)
|
|
1490
|
+
return (jsx(Flex, { justify: "end", dataTestId: dataTestId, children: jsxs(Flex, { className: "h-9 gap-0 divide-x rounded-md border border-slate-300 bg-white dark:divide-slate-700 dark:border-slate-700 dark:bg-slate-800", children: [jsx(PaginationItem, { title: "First page", onClick: () => setCurrentPage(0), disabled: !currentPage || disabled, dataTestId: `${dataTestId}-first-page`, children: jsx(ChevronsLeftIcon, { className: "h-4 w-4" }) }), jsx(PaginationItem, { title: "Previous page", onClick: () => currentPage && setCurrentPage(currentPage - 1), disabled: !currentPage || disabled, dataTestId: `${dataTestId}-previous-page`, children: jsx(ChevronLeftIcon, { className: "h-4 w-4" }) }), pagination.map((page, index) => (jsx(PaginationItem, { active: page !== '...' && page - 1 === currentPage, title: page !== '...' ? `Page ${page}` : undefined, onClick: page !== '...' ? () => setCurrentPage(page - 1) : undefined, disabled: page === '...' || disabled, dataTestId: `${dataTestId}-page-${page}`, children: page }, index))), jsx(PaginationItem, { title: "Next page", onClick: () => currentPage + 1 < totalPages && setCurrentPage(currentPage + 1), disabled: !totalPages || currentPage + 1 === totalPages || disabled, dataTestId: `${dataTestId}-next-page`, children: jsx(ChevronRightIcon, { className: "h-4 w-4" }) }), jsx(PaginationItem, { title: "Last page", onClick: () => setCurrentPage(Math.floor(totalItems && !(totalItems % pageSize)
|
|
1489
1491
|
? (totalItems - 1) / pageSize
|
|
1490
|
-
: totalItems / pageSize)), disabled: currentPage + 1 === totalPages || disabled, dataTestId: `${dataTestId}-last-page`, children: jsx(ChevronsRightIcon, { className: "h-4 w-4" }) })] }) }));
|
|
1492
|
+
: totalItems / pageSize)), disabled: !totalPages || currentPage + 1 === totalPages || disabled, dataTestId: `${dataTestId}-last-page`, children: jsx(ChevronsRightIcon, { className: "h-4 w-4" }) })] }) }));
|
|
1491
1493
|
};
|
|
1492
1494
|
const PaginationItem = (_a) => {
|
|
1493
1495
|
var { children, active, disabled } = _a, props = __rest(_a, ["children", "active", "disabled"]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tw-react-components",
|
|
3
3
|
"description": "A set of React components build with TailwindCSS to make a nice dashboard.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.170",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://bacali95.github.io/tw-react-components",
|
|
7
7
|
"type": "module",
|