@sikka/hawa
Version:
Modern UI Kit made with Tailwind
126 lines (123 loc) • 4.77 kB
JavaScript
"use client";
// elements/pagination/Pagination.tsx
import React from "react";
import { Pagination as PaginationPrimitive } from "react-headless-pagination";
// util/index.ts
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
function cn(...inputs) {
return twMerge(clsx(inputs));
}
// elements/pagination/Pagination.tsx
var Pagination = ({
direction,
totalPages,
currentPage
}) => {
const [page, setPage] = React.useState(currentPage || 0);
const handlePageChange = (page2) => {
setPage(page2);
};
return /* @__PURE__ */ React.createElement(
PaginationPrimitive,
{
totalPages,
edgePageCount: 2,
middlePagesSiblingCount: 1,
currentPage: page,
setCurrentPage: handlePageChange,
className: "hawa-flex hawa-h-9 hawa-w-full hawa-select-none hawa-items-center hawa-text-sm hawa-transition-all",
truncableText: "...",
truncableClassName: "hawa-w-10 hawa-px-0.5 hawa-text-center"
},
/* @__PURE__ */ React.createElement(
PaginationPrimitive.PrevButton,
{
as: /* @__PURE__ */ React.createElement(
"button",
{
"aria-label": "Previous Table Page",
className: cn(
"hawa-min-w-9 hawa-flex hawa-h-9 hawa-w-9 hawa-items-center hawa-justify-center hawa-rounded hawa-border hawa-bg-card",
direction === "rtl" && "hawa-rotate-180"
),
style: { minWidth: 36 }
},
/* @__PURE__ */ React.createElement(
"svg",
{
xmlns: "http://www.w3.org/2000/svg",
width: "24",
height: "24",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round"
},
/* @__PURE__ */ React.createElement("path", { d: "m15 18-6-6 6-6" })
)
),
className: cn(
"hawa-mr-2 hawa-flex hawa-items-center hawa-text-gray-500 hover:hawa-text-gray-600 dark:hover:hawa-text-gray-200",
{
"hawa-cursor-pointer": page !== 0,
"hawa-opacity-50": page === 0
}
)
},
"Previous"
),
/* @__PURE__ */ React.createElement("nav", { className: "hawa-flex hawa-flex-grow hawa-justify-center" }, /* @__PURE__ */ React.createElement("ul", { className: "hawa-flex hawa-items-center hawa-gap-1" }, /* @__PURE__ */ React.createElement(
PaginationPrimitive.PageButton,
{
className: "hawa-tap-highlight-transparent hawa-text-default-foreground data-[focus-visible=true]:hawa-outline-focus data-[disabled=true]:hawa-text-default-300 hawa-min-w-9 hawa-text-small hawa-box-border hawa-flex hawa-h-9 hawa-w-9 hawa-cursor-pointer hawa-touch-none hawa-select-none hawa-flex-wrap hawa-items-center hawa-justify-center hawa-truncate hawa-rounded hawa-border hawa-bg-card hawa-outline-none hawa-transition-all hover:hawa-scale-[1.1] data-[disabled=true]:hawa-pointer-events-none data-[focus-visible=true]:hawa-z-10 data-[pressed=true]:hawa-scale-[0.97] data-[focus-visible=true]:hawa-outline-2 data-[focus-visible=true]:hawa-outline-offset-2",
activeClassName: "hawa-bg-primary hawa-text-primary-foreground hawa-transition-all"
}
))),
/* @__PURE__ */ React.createElement(
PaginationPrimitive.NextButton,
{
as: /* @__PURE__ */ React.createElement(
"button",
{
"aria-label": "Previous Table Page",
className: cn(
"hawa-min-w-9 hawa-flex hawa-h-9 hawa-w-9 hawa-items-center hawa-justify-center hawa-rounded hawa-border hawa-bg-card",
direction === "ltr" && "hawa-rotate-180"
),
style: { minWidth: 36 }
},
/* @__PURE__ */ React.createElement(
"svg",
{
xmlns: "http://www.w3.org/2000/svg",
width: "24",
height: "24",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round"
},
/* @__PURE__ */ React.createElement("path", { d: "m15 18-6-6 6-6" })
)
),
className: cn(
"hawa-mr-2 hawa-flex hawa-items-center hawa-text-gray-500 hover:hawa-text-gray-600 dark:hover:hawa-text-gray-200",
{
"hawa-cursor-pointer": page !== totalPages - 1,
"hawa-opacity-50": page === totalPages - 1
}
)
},
"Next"
)
);
};
export {
Pagination
};
//# sourceMappingURL=index.mjs.map