UNPKG

@transkripid/flowbite-react

Version:

Official React components built for Flowbite and Tailwind CSS - Transkrip.id fork

62 lines (61 loc) 2.53 kB
import { jsxs as n, jsx as s } from "react/jsx-runtime"; import { HiChevronLeft as j, HiChevronRight as k } from "react-icons/hi"; import { twMerge as l } from "tailwind-merge"; import { mergeDeep as y } from "../../helpers/merge-deep.mjs"; import { getTheme as T } from "../../theme-store/index.mjs"; import { PaginationButton as d, PaginationNavigation as h } from "./PaginationButton.mjs"; import { range as w } from "./helpers.mjs"; const N = ({ className: b, currentPage: i, layout: m = "pagination", nextLabel: g = "Next", onPageChange: c, previousLabel: v = "Previous", renderPaginationButton: f = (a) => /* @__PURE__ */ s(d, { ...a }), showIcons: o = !1, theme: x = {}, totalPages: t, ...M }) => { const a = y(T().pagination, x), r = Math.min(Math.max(m === "pagination" ? i + 2 : i + 4, 5), t), p = Math.max(1, r - 4), u = () => { c(Math.min(i + 1, t)); }, C = () => { c(Math.max(i - 1, 1)); }; return /* @__PURE__ */ n("nav", { className: l(a.base, b), ...M, children: [ m === "table" && /* @__PURE__ */ n("div", { className: a.layout.table.base, children: [ "Showing ", /* @__PURE__ */ s("span", { className: a.layout.table.span, children: p }), " to ", /* @__PURE__ */ s("span", { className: a.layout.table.span, children: r }), " of ", /* @__PURE__ */ s("span", { className: a.layout.table.span, children: t }), " Entries" ] }), /* @__PURE__ */ n("ul", { className: a.pages.base, children: [ /* @__PURE__ */ s("li", { children: /* @__PURE__ */ n(h, { className: l(a.pages.previous.base, o && a.pages.showIcon), onClick: C, disabled: i === 1, children: [ o && /* @__PURE__ */ s(j, { "aria-hidden": !0, className: a.pages.previous.icon }), v ] }) }), m === "pagination" && w(p, r).map((e) => /* @__PURE__ */ s("li", { "aria-current": e === i ? "page" : void 0, children: f({ className: l(a.pages.selector.base, i === e && a.pages.selector.active), active: e === i, onClick: () => c(e), children: e }) }, e)), /* @__PURE__ */ s("li", { children: /* @__PURE__ */ n(h, { className: l(a.pages.next.base, o && a.pages.showIcon), onClick: u, disabled: i === t, children: [ g, o && /* @__PURE__ */ s(k, { "aria-hidden": !0, className: a.pages.next.icon }) ] }) }) ] }) ] }); }; N.displayName = "Pagination"; const S = Object.assign(N, { Button: d }); export { S as Pagination }; //# sourceMappingURL=Pagination.mjs.map